如何解决错误:[$ rootScope:infdig] 10 $ digest()迭代达成。中止?

时间:2015-10-22 10:06:49

标签: angularjs cookies gruntjs

我需要设置并获取cookie值,因为我正在使用以下代码。但这是投掷错误。我该如何解决这个问题

我的代码

angular.module('appmodule',['ngCookies']).controller('myctl',function ( $rootScope, $cookieStore) {

var vm = this;
var lastVal = $cookieStore.get('lastValue');
        if (!lastVal) {
            $rootScope.lastVal = 1;
        } else {
            $rootScope.lastVal = lastVal + 1;
        }
        $cookieStore.put('lastValue', $rootScope.lastVal);
});

错误

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [null,[{"msg":"fn: ngModelWatch"},                 {"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":true},{"msg":"fn: expressionInputsWatch","newVal":true},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{}},{"msg":"fn: ngModelWatch"},{"msg":"vm.showConfrimError"},{"msg":"fn: expressionInputWatch","newVal":{}},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":true},{"msg":"fn: expressionInputsWatch","newVal":true},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}}],null,[{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":true},{"msg":"fn: expressionInputsWatch","newVal":true},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{}},{"msg":"fn: ngModelWatch"},{"msg":"vm.showConfrimError"},{"msg":"fn: expressionInputWatch","newVal":{}},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":""},{"msg":"fn: expressionInputWatch","newVal":true},{"msg":"fn: expressionInputsWatch","newVal":true},{"msg":"fn: ngModelWatch"},{"msg":"fn: expressionInputWatch","newVal":{"has-error":false}}]]
http://errors.angularjs.org/1.3.20/$rootScope/infdig?p0=10&p1=%5Bnull%2C%5B%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputsWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22vm.showConfrimError%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputsWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%5D%2Cnull%2C%5B%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputsWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22vm.showConfrimError%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%7D%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%22%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputsWatch%22%2C%22newVal%22%3Atrue%7D%2C%7B%22msg%22%3A%22fn%3A%20ngModelWatch%22%7D%2C%7B%22msg%22%3A%22fn%3A%20expressionInputWatch%22%2C%22newVal%22%3A%7B%22has-error%22%3Afalse%7D%7D%5D%5D

请提前帮助我。

0 个答案:

没有答案