我在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