2017-10-19 56 views
0

我正在使用angular2,当我点击保存按钮时,我想将智能表内容添加到新的json文件中。可能吗 ?保存单击按钮时的智能表内容

source: LocalDataSource = new LocalDataSource(); 
 
    constructor(private http : Http){ 
 
     this.http.get('http://192.168.0.100:8000/json1') 
 
     .map(response => response.json()) 
 
     .subscribe(data =>{ this.obj = data 
 
     this.source.load(this.obj);}); 
 
    } 
 
    
 
    SaveData() 
 
    { 
 
     
 
    alert(JSON.stringify(this.Cost)); 
 
    // this is function which will active when the save button is pressed. 
 
    }

enter image description here

当点击保存按钮我要覆盖从服务器现有json1文件。我有任何解决方案? 在此先感谢

回答

0

您需要制作一个覆盖服务器上的数据的Web服务。您可以在客户端或本地存储中覆盖此数据,但为了更新服务器,您需要制作一项服务,用您的更改覆盖JSON文件。

+0

谢谢你的时间。我使用LUA服务器端脚本语言来完成这个过程。如何将对象发布到LUA 我使用过:this.http.post('http://192.168.0.100:80/login/save.lua',JSON.stringify(this.Cost))。这是对的吗 ??但我无法从lua访问它 –