这是一个 ngRepeat,它为用户重复警报。我想在一段时间内一一显示每个警报。我正在使用 ngShow 和一个计数器变量$scope.showedItem。
模板:
<div class="container" >
<div ng-repeat="headerNotification in headerNotification.list" ng-show="{{showedItem==$index}}">
<h3>{{headerNotification.getText()}}</h3>
<button ng-click="headerNotification.do()" class="btn btn-warning">{{headerNotification.getButtonText()}}</button>
</div>
</div>
控制器:
componentHeaderModule.controller('headerController', [
'$rootScope',
'$scope',
'componentHeaderNotification',
'$interval',
function ($rootScope, $scope, componentHeaderNotification, $interval)
{
...
$scope.showedItem = 1;
$interval(function(){
$scope.showedItem++;
if ($scope.showedItem > $scope.headerNotification.list.length)
$scope.showedItem = 0;
}, 5000);
}]);
当我查看DeveloperTool时,我看到ng-show值每 5 秒更改一次,但是,视图没有刷新,始终显示相同的警报。甚至,项目类没有改变。
可能是什么问题呢?我对双向绑定的理解是一个很大的错误?