我有,我有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對不起,我忘記了,請參閱更新 –