应用加载期间的AngularJS异常

时间:2013-11-23 20:21:54

标签: javascript angularjs exception

我遇到以下例外,我不知道为什么

Exception #1
Uncaught ReferenceError: $window is not defined directives.js:746
(anonymous function) directives.js:746

该指令非常简单:

App.directive('diName', ['$window', function($window) {...}])

   Exception #2
    Error: [ng:areq] http://errors.angularjs.org/1.2.1/ng/areq?p0=AppCtrl&p1=not%20a%20function%2C%20got%20undefined
            at Error (<anonymous>)
            at bower_components/angular/angular.min.js:6:447
            at bower_components/angular/angular.min.js:18:250)
            at bower_components/angular/angular.min.js:18:337)
            at bower_components/angular/angular.min.js:62:72
            at bower_components/angular/angular.min.js:49:117
            at p bower_components/angular/angular.min.js:7:361)
            at B bower_components/angular/angular.min.js:48:492)
            at h bower_components/angular/angular.min.js:43:24)
            at h bower_components/angular/angular.min.js:43:41) angular.js:9101
        (anonymous function) angular.js:9101
        (anonymous function) angular.js:6706
        g.$apply angular.js:11678
        (anonymous function) angular.js:1285
        d angular.js:3616
        Xb.c angular.js:1283
        Xb angular.js:1297
        xhrCallback home:10


        Uncaught Error: [ng:btstrpd] http://errors.angularjs.org/1.2.1/ng/btstrpd?p0=document MINERR_ASSET:20

按如下方式进行手动引导:

<script>
    angular.element(document).ready(function () {
      function xhrCallback() {

        <some XHR Processing Here>

        angular.module('App', []).value('X', <X-value>);
        angular.module('App', []).value('Y', <Y-value>);

        angular.bootstrap(document, ['App']);
      };

      <XHR request here>

    });
</script>

注意:有时应用程序加载正常...所以看起来像一些时间问题?

0 个答案:

没有答案