2014-09-18 3 views
0

Приложение my angularjs работает нормально, пока я не внес изменений. С тех пор я получаю следующую ошибку (взятую из Firebug). Я не знаю, какая часть кода вызывает эту ошибку. Поэтому я вернул свои изменения, даже тогда я получаю ту же ошибку.Angularjs, неспособный запустить угловое приложение js

Из этой трассировки стека ошибок, есть ли у меня возможность узнать, какая часть моего углового кода js вызывает эту проблему? Поскольку мое приложение является большим, я не знаю, какую часть кода я могу предоставить вам для справки, не зная, какая часть кода вызвала эту ошибку.

В этой трассировке стека ошибок я не нашел ни одной ссылки на имя функции, имя объекта и т. Д., Которые я создал в моем приложении angularjs. Все ссылки на линии в этом номере показывают только строки файла Angular.js. Может ли кто-нибудь направить меня, как я могу узнать, какая часть моего кода angularjs вызывает эту ошибку?

Error: node is undefined [email protected]://localhost/dashboard2/js/d3angular/angular.js:5989:13 [email protected]://localhost/dashboard2/js/d3angular/angular.js:5989:13 [email protected]://localhost/dashboard2/js/d3angular/angular.js:6573:1 [email protected]://localhost/dashboard2/js/d3angular/angular.js:5986:15 [email protected]://localhost/dashboard2/js/d3angular/angular.js:5989:13 [email protected]://localhost/dashboard2/js/d3angular/angular.js:5891:30 bootstrap/doBootstrap/</<@http://localhost/dashboard2/js/d3angular/angular.js:1384:11 $RootScopeProvider/this.$get</[email protected]://localhost/dashboard2/js/d3angular/angular.js:12412:16 $RootScopeProvider/this.$get</[email protected]://localhost/dashboard2/js/d3angular/angular.js:12510:18 bootstrap/doBootstrap/<@http://localhost/dashboard2/js/d3angular/angular.js:1382:9 [email protected]://localhost/dashboard2/js/d3angular/angular.js:3869:14 bootstrap/[email protected]://localhost/dashboard2/js/d3angular/angular.js:1380:1 [email protected]://localhost/dashboard2/js/d3angular/angular.js:1394:1 [email protected]://localhost/dashboard2/js/d3angular/angular.js:1307:5 @http://localhost/dashboard2/js/d3angular/angular.js:21459:5 [email protected]://localhost/dashboard2/js/d3angular/angular.js:2509:7 createEventHandler/eventHandler/<@http://localhost/dashboard2/js/d3angular/angular.js:2780:7 [email protected]://localhost/dashboard2/js/d3angular/angular.js:330:11 createEventHandler/[email protected]://localhost/dashboard2/js/d3angular/angular.js:2779:5 
consoleLog/<()angular.js (line 9778) 
$ExceptionHandlerProvider/this.$get</<(exception= 
TypeError: node is undefined 


childLinkFn(scope, node.childNodes, undefined, boundTranscludeFn); 

, cause=undefined)angular.js (line 7216) 
$RootScopeProvider/this.$get</Scope.prototype.$apply()angular.js (line 12512) 
bootstrap/doBootstrap/<(scope=Scope { $id="002", $$childTail=Scope, $$childHead=Scope, more...}, element=Object[html.ng-scope], compile=compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext), injector=Object { invoke=invoke(), instantiate=instantiate(), get=getService(), more...}, animate=Object { enter=function(), leave=function(), move=function(), more...})angular.js (line 1382) 
invoke(fn=function(scope, element, compile, injector, animate), self=undefined, locals=undefined)angular.js (line 3869) 
bootstrap/doBootstrap()angular.js (line 1380) 
bootstrap(element=Object[html.ng-scope], modules=["ng", ["$provide", function($provide)], "myApp"])angular.js (line 1394) 
angularInit(element=Document testDashboard.do, bootstrap=bootstrap(element, modules))angular.js (line 1307) 
angular.js()angular.js (line 21459) 
trigger()angular.js (line 2509) 
createEventHandler/eventHandler/<(fn=trigger())angular.js (line 2780) 
forEach(obj=Object { 0=trigger()}, iterator=function(fn), context=undefined)angular.js (line 330) 
createEventHandler/eventHandler(event=DOMContentLoaded , type=undefined)angular.js (line 2779) 


return logFn.apply(console, args); 

Ниже приведены некоторые из шаблонов, которые я использовал в своем контроллере и их компиляцию.

var template = ' <div class="table-container"> <smart-table config="globalConfig" columns="columnCollection" rows="rowCollection"></smart-table> </div> '; 


         angular.element(
             document.querySelector('.snap-content')) 
           .append($compile(template)($scope)); 



var template = ' <div class="col"> ' 
         + ' <p class="graphtitle"> NetSpend Over Time </p> <nvd3 id = "chart3" options="netspendovertime_options" data="netspendovertime_data"></nvd3> </div>'; 


        angular 
          .element(
            document.querySelector('.snap-content')) 
          .append($compile(template)($scope)); 

Перед компиляцией каждого шаблона я удаляю большинство существующих элементов DOM шаблонов, как показано ниже. Есть ли какие-либо ошибки в этом подходе?

// Remove the previously plotted graphs 
        var charts = angular.element(document.body) 
          .find('nvd3') 
        var cntGraphs = charts.length; 

        if (cntGraphs) { 
         while (cntGraphs > 0) { 
          console.log(charts[cntGraphs - 1].parentNode.remove()) 
          charts[cntGraphs - 1].remove(); 
          cntGraphs = cntGraphs - 1; 
         } 

        } 

        // Remove the previous Titles 
        var tiltles = angular.element(document.body).find('p') 
        var cntTiltles = tiltles.length; 

        if (cntTiltles) { 
         while (cntTiltles > 0) { 
          tiltles[cntTiltles - 1].remove(); 
          cntTiltles = cntTiltles - 1; 
         } 

        } 

        // Remove Welcome Images 
        var images = angular.element(document.body).find('img') 
        var cntImages = images.length; 

        if (cntImages) { 
         while (cntImages > 0) { 
          images[cntImages - 1].remove(); 
          cntImages = cntImages - 1; 
         } 

        } 

        // Remove All Smart Tables 
        var smartTlbs = angular.element(document.querySelector('.smart-table')) 

        var cntsmartTlbs = smartTlbs.length; 

        if (cntsmartTlbs) { 
         while (cntsmartTlbs > 0) { 
          smartTlbs[cntsmartTlbs - 1].remove(); 
          cntsmartTlbs = cntsmartTlbs - 1; 
         } 

        } 
+0

Есть ли у вас какие-либо директивы или контроллеры, которые манипулируют DOM в любом месте, кроме функции связи директивы? –

+0

Да, Джефф Кросс, я собираю шаблоны в своем контроллере и редактировал мой вопрос с образцами шаблонов, которые я использовал. –

+0

Jeff Cross, кроме этого манипулирования Dom в контроллере Я не создал никакой директивы для управления DOM. Однако я использовал некоторые официальные директивы, такие как nvd3, smartTable.table, угловые привязки, ui.tree, ui.bootstrap. Я чувствую, что все эти директивы управляют Dom только в функции ссылок. –

ответ

0

После траты на это достаточное количество времени, небольшая мысль пришла, чтобы проверить приложение в хроме. Затем в chrome я получил полную трассировку стека, я не знаю, почему Firebug пропустил эту информацию. Корневая проблема возникла из моего $ scope.allNeedsMet (что-то связанное с underscore.js).

С помощью этого опыта я предлагаю разработчикам попробовать использовать различные браузеры для журналов ошибок, тогда он может реально сэкономить ваше время в таких проблемах.

ReferenceError: _ is not defined 
     at Scope.$scope.allNeedsMet (http://localhost/dashboard2/js/controllers.js:160:22) 
     at Object.get (http://localhost/dashboard2/js/d3angular/angular.js:10567:21) 
     at Scope.$digest (http://localhost/dashboard2/js/d3angular/angular.js:12243:40) 
     at Scope.$apply (http://localhost/dashboard2/js/d3angular/angular.js:12516:24) 
     at http://localhost/dashboard2/js/d3angular/angular.js:1382:15 
     at Object.invoke (http://localhost/dashboard2/js/d3angular/angular.js:3869:17) 
     at doBootstrap (http://localhost/dashboard2/js/d3angular/angular.js:1380:14) 
     at bootstrap (http://localhost/dashboard2/js/d3angular/angular.js:1394:12) 
     at angularInit (http://localhost/dashboard2/js/d3angular/angular.js:1307:5) 
     at http://localhost/dashboard2/js/d3angular/angular.js:21459:5 angular.js:9778(anonymous function) angular.js:9778(anonymous function) 
angular.js:7216Scope.$digest angular.js:12270Scope.$apply angular.js:12516(anonymous function) 
angular.js:1382invoke angular.js:3869doBootstrap angular.js:1380bootstrap angular.js:1394angularInit 
angular.js:1307(anonymous function) angular.js:21459trigger angular.js:2509(anonymous function) angular.js:2780forEach angular.js:330eventHandler 
Смежные вопросы