AngularJS无法加载模块 [英] AngularJS fail to load module

查看:910
本文介绍了AngularJS无法加载模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:这只是与IE浏览器发生(在IE10测试)

This only happens with IE (tested on IE10)

我不过是加载罚款最初,一个应用程序,刷新时,它提供此错误:

I have a app that loads fine initially, however, when refreshed it gives this error:

SCRIPT5022:无模块:myAppModule

SCRIPT5022: No module: myAppModule

myAppModule是被加载后angular.js装入app.js中定义的角度模块

myAppModule is an angular module defined in app.js which is loaded after loading angular.js

angular.module('myAppModule', []);

,并通过在自动自举:

and is auto-bootstrapped via:

<html ng-app="myAppModule">

脚本加载如下(无AMD装载机):

The scripts are loaded as follows (no AMD loader):

<script>window.jQuery ||
    document.write('<script src="js/vendor/jquery-1.8.0.min.js"></script>')</script>
<script>window.angular ||
    document.write('<script src="js/vendor/angular-1.0.2.min.js"></script>')</script>

<script src="js/app.js"></script>
<script src="js/controller.js"></script>

我估计angularjs是越来越首先加载和自动自举应用程序,但app.js尚未加载

I reckon that angularjs is getting loaded first and auto-bootstrapping the application, but app.js has not been loaded yet

推荐答案

好吧,我不知道为什么自动引导失败,但如果我手动引导应用程序,它工作正常。

Ok I don't know why auto-bootstrapping is failing, but if I manually bootstrap the application it works fine.

例如

<html>

...

<script src="js/app.js"></script>
<script src="js/controller.js"></script>
<script>angular.bootstrap(document, ['myAppModule']);</script>

这篇关于AngularJS无法加载模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆