2017-03-01 65 views
2

我有當過一些數據發生改變時它獲取更新的對象,我需要到以前的和更新的數據存儲到一個數組並檢索它需要的時候更新與新對象的數組

/* currently i could get 1 data i need multiple data stored to a storage as array*/ 
    get(){ 
     this.storage.get('uploaded').then((data) => { 
      console.log("get data", JSON.parse(data));   
     }); 
    } 

    set(){ 
     var obj = { upload: true, 
        file: file.audio //this will hold an object which vary when required 
        } 

     this.storage.set('uploaded', JSON.stringify(obj)); 
    } 
+0

是提交對象的陣列?我想你需要做任何文件陣列,並做一個推動,如果你需要有多個值 –

+0

是文件是一個對象可以讓我創建一個樣本 –

+0

你有一個簡單的@rahul希望可以幫助 –

回答

2

你可以使用push()數組的方法用新數據更新數組。

var obj = new Array(); 
obj.push();// use this whenever you have new data 

並使用它來訪問值

for (var i in obj) { 
    //access values using obj[i] 
} 
+0

@YokeshVaradhan你可以upvote答案 –