我有,我有angularjs和NG-重复的问题挣扎没有更新,我有被NG-重复生成的表:NG重复
<div>
<select ng-model="item" ng-controller="dropdown"
ng-change="update(item)">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</select>
<table ng-controller="repeatTest">
<tr>
<td>name</td>
<td>family name</td>
<td>score</td>
</tr>
<tr ng-repeat="item in list">
<td>{{ item.name }}</td>
<td>{{ item.familyName }}</td>
<td>{{ item.score }}</td>
</tr>
</table>
</div>
和我的js代码如下:
var app = angular.module("myModule", []);
app.service('sharedService', function() {
this.list = [];
});
app.controller('dropdown', function($scope, sharedService) {
$scope.update = function(item) {
if (item == "volvo") {
sharedService.list = [ {
name : 'A',
familyName : 'AA',
score : '10'
}, {
name : 'B',
familyName : 'BB',
score : '5'
} ];
$scope.list = sharedService.list;
console.log($scope.list);
} else {
sharedService.list = [ {
name : 'zzz',
familyName : 'zzz',
score : '100'
}, {
name : 'zz',
familyName : 'zz',
score : '70'
} ];
$scope.list = sharedService.list;
}
}
});
app.controller('repeatTest', function($scope, sharedService) {
sharedService.list = [ {
name : 'xxx',
familyName : 'xxx',
score : 'xxx'
}, {
name : 'xx',
familyName : 'xx',
score : 'xx'
} ];
$scope.list = sharedService.list;
});
现在我的问题是SI在页面加载生成的,当我改变选择框,虽然它应该是因为我绑定表,以列表这是在范围定义不会再更改表和我假设每当范围变化表也应该受到影响。谁能帮忙?
和'ng-controller =“repeatTest”'定义在哪里? –
@MaciejDobrowolski对不起,我忘记了,请参阅更新 –