我有HTML結構就是這樣,不被顯示grid.message.success範圍變量沒有更新模板
<div ng-controller="MYAPPCtrl">
....
<div ng-controller="UserCtrl">
....
<div ng-controller="GridCtrl>
<div ng-show="grid.message.success" class="success-msg">{{grid.message.success}}</div>
<div ng-show="grid.message.error" class="error-msg">{{grid.message.error}}</div>
</div>
<button ng-click="deleteUsers()"... />
</div>
</div>
這裏是我的js代碼
function MYAPPCtrl($scope) {
$scope.gridMessage = {
success: null,
error: null
}
$scope.setGridMessage = function(d) {
$scope.gridMessage = d;
}
}
function UserCtrl($scope) {
$scope.deleteUsers = function() {
$scope.setGridMessage({success: 'hello'});
})
}
function GridCtrl($scope) {
$scope.grid = {
message: $scope.gridMessage,
};
}
+1,因爲它認爲,這是事實上的主要問題 – tasseKATT