[英]Angular.js stops execution (probably general javascript error)
I developed a web portal where users can log in, manage their account stuff, and so on. 我开发了一个Web门户,用户可以在其中登录,管理其帐户资料等。 Technically, it's a JSP/Servlet application running on Tomcat, delivering pages as templates.
从技术上讲,它是在Tomcat上运行的JSP / Servlet应用程序,将页面作为模板交付。 Each site has an angular app with Controllers, etc. and loads data from JSON-Service (Spring MVC).
每个站点都有一个带有Controllers等的角度应用程序,并从JSON-Service(Spring MVC)加载数据。 It's not the classical "single page app" but a "single page per service" app (each page has it's own angular app with sub-views, directives, etc.)
它不是传统的“单页应用程序”,而是“每项服务单页”应用程序(每个页面都有它自己的带有副视图,指令等的角度应用程序)
That all works great, but from time to time I'm facing with a strange error, where javascript-execution seems to stop completely (see screenshot http://i.stack.imgur.com/EF28q.png ). 一切都很好,但有时我会遇到一个奇怪的错误,即javascript执行似乎完全停止了(请参阅屏幕快照http://i.stack.imgur.com/EF28q.png )。 The green ajax-loader should be hidden by angular expression, you see the curly braces in breadcumb navigation and content, success and error-messages appear both, but should be hidden.
绿色的Ajax加载程序应通过角度表达式隐藏,您会看到面包导航和内容中的花括号,成功消息和错误消息同时出现,但应该隐藏。
After some hours of debugging I found out: 经过几个小时的调试,我发现:
I followed the angular guidelines for Internet Explorer, so I prefixed all directives with data-*, etc. and I followed the "Note on minification" ( http://docs.angularjs.org/tutorial/step_05 ), so my angular controller/services/directives follow the bracket notation: app.controller('Ctrl', ['$scope', '...', function($scope, ...){}]); 我遵循了Internet Explorer的角度指南,因此在所有指令前都加上了data- *等,然后遵循“缩小提示”( http://docs.angularjs.org/tutorial/step_05 ),因此我的角度控制器/ services / directives遵循方括号表示法:app.controller('Ctrl',['$ scope','...',function($ scope,...){}]);
Any help would be greatly appreciated 任何帮助将不胜感激
Florian 弗洛里安
you can try this: 您可以尝试以下方法:
App.controller('Ctrl', ['$scope', '$http', ...... ,
function ($scope, $http, ......) {
}]);
you need to use this way to avoid $scope , $http, ... parameters be compressed 您需要使用这种方式来避免$ scope,$ http等参数被压缩
Seems like the angular execution has not even started. 似乎角度执行尚未开始。 Because of the sporadic nature of the error, I would consider some timing problem with the DOM.
由于错误的偶发性,我将考虑DOM的一些时序问题。 Do you use RequireJS for async script loading?
您是否使用RequireJS进行异步脚本加载?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.