我$timeout在Modal控制器中有几个表达式
App.controller('ModalCtrl', function ($scope, $timeout) {
for (var i = 0; i < 10; i++) {
(function () {
var timer = $timeout(function () {
console.log('timer')
}, 1000);
})()
}
})
Run Code Online (Sandbox Code Playgroud)
我需要在调用模态时清除所有计时器:
App.controller('MainCtrl', function ($scope, $modal, $timeout) {
$scope.showMap = function () {
var modal = $modal.open({
templateUrl: 'modalap.html',
controller: 'modalCtrl',
})
modal.result.then(function () { //fires when modal is resolving
}, function () { //fires when modal is invoking
});
} })
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
PS对不起代码格式错误.我不知道为什么,但我不能更好地格式化它.我在这里重复了代码:
这是我的代码:
<h1 ng-repeat="item in func()">something</h1>
$scope.func = function(){
return [{"property" : "value1"},{"property": "value2"}];
}
Run Code Online (Sandbox Code Playgroud)
在Angular.js v.1.1.1中,没有错.在Angular.JS v 1.2.1中,我得到了一个infDig错误.
你能解释一下这种情况吗?非常感谢.
infinite-loop angularjs angularjs-ng-repeat angularjs-infdig