角度 1.5 不更新 ng-repeat
Angular 1.5 not update ng-repeat
>我通过ng-repeat显示一个表格
<div ng-app="spApp">
<div ng-controller="spListCtrl as MyList">
<table width="100%" cellpadding="10" cellspacing="2">
<thead>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>CellPhone</th>
<th>Update</th>
</thead>
<tbody>
<tr ng-repeat="item in MyList.Contacts track by $index">
<td class="align-center"><input type="text" ng-model="MyList.Contacts[$index].FirstName"> </input></td>
<td class="align-center">{{MyList.Contacts[$index].Title}}</td>
<td class="align-center">{{MyList.Contacts[$index].Email}}</td>
<td class="align-center">{{MyList.Contacts[$index].CellPhone}}</td>
<td class="align-center"><button ng-click="ShowNewForm(MyList.Contacts[$index])">Изменить</button></td>
</tr>
</tbody>
</table>
通过服务加载 ajax 数据
spApp.controller('spListCtrl', function spListCtrl($scope,dataService){
var Contacts;
var promiseObj=dataService.getContacts();
promiseObj.then(function(value) {
Contacts=value;
});
我签入调试,数据被分配为正常,但不显示。什么没有尝试过,告诉我我做错了什么。
在使用controllerAs
模式时,将数据绑定变量绑定到this
(控制器函数上下文),以便您可以使用别名MyList
(控制器函数的实例)在HTML上访问它们。
法典
spApp.controller('spListCtrl', function spListCtrl(dataService){
var self = this
var promiseObj=dataService.getContacts();
promiseObj.then(function(value) {
self.Contacts=value.data;
});
});
在里面ng-repeat
使用item
来绑定工作。
<tr ng-repeat="item in MyList.Contacts track by $index">
<td class="align-center"><input type="text" ng-model="item.FirstName"> </input></td>
<td class="align-center">{{item.Title}}</td>
<td class="align-center">{{item.Email}}</td>
<td class="align-center">{{item.CellPhone}}</td>
<td class="align-center"><button ng-click="ShowNewForm(item)">Изменить</button></td>
</tr>
相关文章:
- 如何使用ng repeat中的选定输入更新我的对象
- 通过使用ng if更新ng repeat加载程序
- Flexslider-通过ng repeat更新图像-宽度不正确
- AngularJS ng repeat没有't在LocalStorage更改时更新(使用store.js)
- 如何只更新ng repeat中的部分元素
- 角度 1.5 不更新 ng-repeat
- 在角度材料对话框数据输入/推送后更新ng-repeat
- 添加重复键对象时如何更新 ng-repeat 列表中的元素
- 从另一个 Angular 控制器更新 ng-repeat
- 如何使用 Angular 更新 NG-Repeat 中的列表
- 更新ng repeat using指令创建的图像
- Angular js -在删除元素后更新ng-repeat list
- 在parse.com成功保存时动态更新ng-repeat行
- AngularJS:如何在数据库源的新数据上更新ng-repeat
- 是否有可能在响应断点更新ng-repeat ?
- 使用Angular js更新ng-repeat中的数据
- 更新ng repeat时,ScrollHeight不变
- AngularJS:显示并更新ng repeat中每个元素的进度条
- 不能简单地使用 ES6 承诺来更新 ng-repeat 中的数据
- 从另一个控制器更新ng-repeat上的复杂滤波器