- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在加载 Angular 应用程序时不断收到此错误。在 Chrome 中刷新几次,我的应用程序将运行,但 IE 和 FF 是不行的。
错误将我链接到此 error page但我真的不明白它说的是什么。
我正在使用 LabsJS 加载我的应用程序包括 Controller 和服务。
// spAppLoader.js
$LAB
.script("../js/app.js").wait()
.script("../js/controllers/userCtrl.js")
.script("../js/controllers/groupCtrl.js")
.script("../js/controllers/siteCtrl.js")
.script("../js/services/userServices.js")
.script("../js/services/groupServices.js")
.script("../js/services/siteServices.js")
标记:
<div id="mdContainer" ng-app="spApp" ng-cloak>
...
</div>
<script type="text/javascript" src="../js/spAppLoader.js"></script>
我想发布更多代码,但我不知道从哪里开始,而且对于 angular,一切都在多个文件中。我通过github上传的.
最佳答案
你应该 manually bootstrap您的应用,因为您使用异步脚本加载器:
$LAB
.script("../js/app.js").wait()
.script("../js/controllers/userCtrl.js")
.script("../js/controllers/groupCtrl.js")
.script("../js/controllers/siteCtrl.js")
.script("../js/services/userServices.js")
.script("../js/services/groupServices.js")
.script("../js/services/siteServices.js")
.wait(function(){
var root = document.getElementById('mdContainer')
angular.bootstrap(root ,['spApp']);
})
angular.bootstrap(root ,['spApp']);
与<div id="mdContainer" ng-app="spApp">
相同只有最后一个会在 DOMContentLoaded event
时自动初始化您的应用程序发生。
使用脚本加载器时,DOMContentLoaded event
可能会在加载所有脚本之前发生,因此您必须等待所有模块脚本,然后手动引导您的应用程序。
在你的例子中,chrome 可能缓存了你的脚本,所以在几次刷新后 DOMContentLoaded event
加载所有脚本后发生。
来自文档:
Automatic Initialization
Angular initializes automatically upon DOMContentLoaded event or when the angular.js script is evaluated if at that time document.readyState is set to 'complete'. At this point Angular looks for the ng-app directive which designates your application root...
Manual Initialization
If you need to have more control over the initialization process, you can use a manual bootstrapping method instead. Examples of when you'd need to do this include using script loaders or the need to perform an operation before Angular compiles a page.
关于javascript - Uncaught Error : [$injector:modulerr] Failed to instantiate module with LABJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21224699/
$injector.instantiate有什么区别, $injector.get和 $injector.invoke在 AngularJS 中? 最佳答案 鉴于以下服务: app.service('
我尝试使用两种方式显式创建依赖关系。两者几乎相同,但我有点困惑使用反射注入(inject)器比普通注入(inject)器有什么优势,推荐使用哪种方式? 使用注入(inject)器 import { I
我对 Angular js 很陌生,以下是我的代码 (function(angular){ var testAngular = angular.mo
在英雄之旅教程的第 5 节中,main.dart 包含以下行: final InjectorFactory injector = self.injector$Injector; 这是错字吗?它在 VS
你好我是 Angular JS 的初学者,当我开始创建模块和 Controller 时,我无法打印我的消息,下面是我的代码 var myModule = angular.module("myFirst
我只是想在 Angular Dart 中尝试路由。我在关注这个https://webdev.dartlang.org/angular/guide/router/1指导,但我收到错误。 这一行给出错误
自从我设置一个与 Angular 一起运行的网络应用程序以来已经有一段时间了。我正在通过一个旧项目回顾我的步骤(尝试在我正在做的页面上实现一个 Controller ,确保 Controller 文件
我正在尝试学习 Angular,但无法正确加载它。我看了一下关于 SO 的类似问题,但找不到我要找的东西。 有人知道为什么会出现这个错误吗?在我看来,我是否正确地调用了我的新应用程序/模块?我的剧本错
我使用环回作为后端,使用 postgresql 作为数据库。所以我尝试使用 lb-service/js。 如果我尝试在 login.js 中包含 lbServices (angular.module(
我正在尝试将表情符号应用程序注入(inject)我的项目。 我添加了emoji.min.js并像这样引用它 现在我也将它注入(inject)到我的项目中,如下所示: angular.module('
当我尝试将 $cookie 包含到我的 Controller 中时出现此错误。 任何人都可以向我解释我做错了什么? 我在 index.html 中有 angular-cookie.js 我在 conf
我正在使用 anguarjs 开发一个应用程序,并出现如下错误: 无法实例化模块 myApp,原因是:错误:[$injector:modulerr] http://errors.angularjs.o
var demoapp = angular.module('demoapp', []); demoapp.controller('SimpleC
我正在尝试通过网络摄像头简单地读取二维码,但我在控制台打开 Angular 帮助页面时遇到此错误,但说使用 ngRoute Error: [$injector:modulerr] http://err
我正在尝试对此进行编码,只是使用路由从第一个页面跳转到另一个页面,但为什么它不起作用,我搜索并使用了很多技巧但仍然失败,请问有人吗? index.html Angular Js
我收到此错误: ncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$inje
我正在尝试创建一个带有 Angular 路由的 SPA(单页应用程序),但是当我将 ndRoute 添加到我的模块时,它给了我这个错误 Uncaught Error: [$injector:modul
this is the error i m getting.这个问题被问了很多次。但是下面的代码在在线编译器中运行良好,但在我的本地系统中运行不佳,即使系统已连接到互联网,它也显示未定义 Angula
我正在尝试学习 Angular 并尝试在基于 Web 的教程之外编写我的第一个 Controller 。我一直在 JS 控制台的标题中收到错误消息,无法弄清楚发生了什么。该链接将我带到一个引用需要包含
我在尝试编写代码时遇到此错误。我已经完成了其他 Stackflow 问题,但找不到答案。是什么导致了这个错误? var app = angular.module("app", ['ui.router'
我是一名优秀的程序员,十分优秀!