Javascript 角度1.5不更新ng重复

Javascript 角度1.5不更新ng重复,javascript,angularjs,Javascript,Angularjs,我通过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</

我通过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>

我签入调试,数据被指定为正常,但不显示。如果没有尝试,请告诉我我做错了什么。

在使用
controllerAs
模式时,请将数据绑定变量绑定到
(控制器函数上下文),以便您可以使用it别名
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
内部使用
进行绑定工作

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

{{item.Title}
{{item.Email}
{{item.mobile}
Изменить

此外,我们可以使用{{item.Title}}代替MyList.Contacts[$index].Title。我们不能吗?其他属性也是如此。使用controllerAs语法时,无需注入
$scope
。您还需要访问promise结果的
.data
属性。e、 g.
self.Contacts=value.data。谢谢!一切顺利。如果值相同,则需要“MyList.Contacts[$index].First Name”。@Lex correct。。Thabks提醒你一声事实上我得赶时间去吃饭。否则我就不会错过这样的机会stuff@Alexey您应该在那里使用item..不需要使用$index访问对象
    <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>