我在AngularJS中有兩個組件。單組分usersList
包含表
<table>
<tbody>
<tr ng-repeat="..."><!--Contains code to repeat the entries in usersList localstorage object--></tr>
</tbody>
</table>
在頁面加載,該組件獲取用戶提供從$ localStorage的一個API,並將其存儲他們的詳細信息列表。 另一種形式editUserProfile
其中的值進行編輯和刪除
app.component("editUserProfile", {
...
controller: function($localStorage, ...) {
vm.$storage = $localStorage;
// Do other things
// Some event (edit) is successful, update the userslist in $localStorage
vm.$storage.usersList = response
}
})
所以基本上,我編輯用戶的詳細信息,並通過使對API的調用刪除用戶,當一個成功的編輯/刪除發生,我刷新usersList的$ localStorage值,它是一個JSON對象。
事情總是起作用,直到更新數據,但是這些更改未反映在usersList組件中。我這樣做是爲了保存對API顯示數據的調用。歡迎任何其他想法。
什麼是$ storage和$ localstorage? – Zooly
我正在使用ngStorage。 $ storage和$ localStorage與ngStorage相關。 –
不要忘了提及那麼:) – Zooly