AngularJS& Ionic - Minified error $ rootScope:infdig,not minified works ok

时间:2015-09-15 17:46:18

标签: javascript angularjs ionic minify

所以,我有大量的js文件,每个控制器一个,每个服务一个,一个用于指令,一个用于过滤器。

在检查完所有内联数组表示法后,我缩小了,我有下一个问题:

Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5D
file:///Users/id/Library/Developer/CoreSimulator/Devices/E17B3C6B-9153-4DDE-84B7-DC37B32AA216/data/Containers/Bundle/Application/C2894260-5ED1-471E-AE80-B17FEC539F22/TheApp.app/www/lib/ionic/js/ionic.bundle.js:8890:32
$digest@file:///Users/id/Library/Developer/CoreSimulator/Devices/E17B3C6B-9153-4DDE-84B7-DC37B32AA216/data/Containers/Bundle/Application/C2894260-5ED1-471E-AE80-B17FEC539F22/TheApp.app/www/lib/ionic/js/ionic.bundle.js:23108:35
$apply@file:///Users/id/Library/Developer/CoreSimulator/Devices/E17B3C6B-9153-4DDE-84B7-DC37B32AA216/data/Containers/Bundle/Application/C2894260-5ED1-471E-AE80-B17FEC539F22/TheApp.app/www/lib/ionic/js/ionic.bundle.js:23333:31
file:///Users/id/Library/Developer/CoreSimulator/Devices/E17B3C6B-9153-4DDE-84B7-DC37B32AA216/data/Containers/Bundle/Application/C2894260-5ED1-471E-AE80-B17FEC539F22/TheApp.app/www/lib/ionic/js/ionic.bundle.js:25059:42
completeOutstandingRequest@file:///Users/id/Library/Developer/CoreSimulator/Devices/E17B3C6B-9153-4DDE-84B7-DC37B32AA216/data/Containers/Bundle/Application/C2894260-5ED1-471E-AE80-B17FEC539F22/TheApp.app/www/lib/ionic/js/ionic.bundle.js:13732:15
file:///Users/id/Library/Developer/CoreSimulator/Devices/E17B3C6B-9153-4DDE-84B7-DC37B32AA216/data/Containers/Bundle/Application/C2894260-5ED1-471E-AE80-B17FEC539F22/TheApp.app/www/lib/ionic/js/ionic.bundle.js:14112:33
2015-09-15 14:32:01.624 TheApp[34155:625632] ERROR:Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.13/$rootScope/infdig?p0=10&p1=%5B%5D, file:///Users/id/Library/Developer/CoreSimulator/Devices/E17B3C6B-9153-4DDE-84B7-DC37B32AA216/data/Containers/Bundle/Application/C2894260-5ED1-471E-AE80-B17FEC539F22/TheApp.app/www/lib/ionic/js/ionic.bundle.js:13736

我不知道为什么会出现这个问题,如果我使用非缩小文件,一切都会像它应该的那样工作,但是使用缩小的文件我会得到这个无限的摘要错误..

我添加了ng-strict-di指令,因此没有注释问题。

导致此行为的原因是什么?

我使用gulp来完成这项工作,这是gulpfile中的任务:(以防需要)

var src_paths = [
    'src/**/*.js'
];
var dist_path = 'www/js';

gulp.task('dist', function() {
    gulp.src(src_paths)
        .pipe(concat('app-test.js'))
        .pipe(header(banner, {
            pkg: pkg
        }))
        .pipe(gulp.dest(dist_path))
        .pipe(uglify())
        .pipe(rename({
            extname: '.min.js'
        }))
        .pipe(header(banner, {
            pkg: pkg
        }))
        .pipe(gulp.dest(dist_path));
});

如果您需要更多细节,请询问,欢迎所有帮助。

2 个答案:

答案 0 :(得分:1)

我有类似的错误。使用角度缩小文件时我得到了无限的摘要错误,使用非缩小版本时没有错误。此外,angular记录的错误消息还有一个不工作的URL。

最终,我发现问题在于使用激活控制器的方法会使用$window.location.assign('#/mypage/page1') ;.我通过改为使用$location.path来修复它。

我假设它导致某些竞争条件与应用路由器只在缩小版本中可见。可能不是你遇到的同样问题,但只想分享我的经验。

答案 1 :(得分:0)

我遇到了同样的问题。该应用程序在非缩小时工作正常,但在缩小时则不行。我在控制台中遇到了同样的错误。

在我的案例中,根本原因在于ui-router州的一个决心。

当决心是这样的时候,这是错误的:

resolve: ['afactory', function (afactory) {
   //....
}]

当决心更改为:

时,它有效
resolve: {
  somename: ['afactory', function (afactory) {
    //....
  }]
}