小编use*_*402的帖子

AngularJS.调用angular-ui模态时清除$ timeout

$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对不起代码格式错误.我不知道为什么,但我不能更好地格式化它.我在这里重复了代码:

timeout angularjs angular-ui

56
推荐指数
1
解决办法
4万
查看次数

具有ng-repeat函数的AngularJS InfDig错误(无限循环),返回对象数组

这是我的代码:

<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错误.

v.1.1.1的小提琴

v.1.2.1的小提琴

你能解释一下这种情况吗?非常感谢.

infinite-loop angularjs angularjs-ng-repeat angularjs-infdig

7
推荐指数
1
解决办法
8880
查看次数