0
不刷新我用液鹼中和AngularJS和有以下問題:名單在我的角度網站
這裏是視圖:
<ion-list>
<ion-item ng-repeat="item in items track by $index" >
<h1>{{item.text}}</h1>
{{item.timestring}}
</ion-item>
</ion-list>
和控制器:
$scope.items = foo.getItems();
方法在foo中看起來像:
foo.loclStorages = JSON.parse(localStorage.getItem("foo"));
foo.getItems = function() {
if (foo.loclStorages === null) {
return [];
} else {
return jsdata.loclStorages.items;
}
};
現在的問題: 當列表爲空且我添加第一個元素時,我首先需要更新站點才能看到它。 當我已經有列表中的項目時,我可以在更新後立即看到它。
我需要做的,也看到它添加的第一個元素後瞬間是什麼?
在你的'ng-repeat'表達式中'$ by index'是什麼?我建議先看看那裏([見文檔](https://docs.angularjs.org/api/ng/directive/ngRepeat))。 – hon2a 2014-11-23 11:02:53