2017-10-19 62 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訪問它 –