Angular.js只加载一半的时间
Angular.js only loading half the times
我遇到了一个angular应用程序的问题。我正在使用凉亭。当我启动服务器时,我有时会得到这个错误:
未捕获错误:[$injector:modulerr]实例化模块myApp失败,原因是:错误:[$injector:modulerr]实例化模块ui失败。路由器由于:错误:[$injector:nomod]模块的ui。路由器不可用!您要么拼错了模块......2)
然后我有时会得到这个错误:
Uncaught SyntaxError: Unexpected identifier angular.js:573
Uncaught TypeError: Cannot read property 'module' of undefined
Uncaught SyntaxError: Unexpected token ILLEGAL
Uncaught ReferenceError: angular is not defined ui-bootstrap-tpls-0.11.0.js:8
Uncaught ReferenceError: angular is not defined app.js:4
Uncaught ReferenceError: angular is not defined
有时css也不能完全加载,但不会得到控制台错误。其他时候它工作得很好。
这是我的代码设置<body ng-app="myApp" class="ng-scope">
<div>
<div ui-view>
</div>
</div>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
<script src="js/create.js"></script>
<script src="js/view.js"></script>
<script src="js/header.js"></script>
<script src="js/form-service.js"></script>
<script src="js/form-directive.js"></script>
<script src="js/field-directive.js"></script>
<script src="js/jquery.dcjqaccordion.2.7.js"></script>
</body>
这是我的应用程序所在的app.js
var myApp = angular.module('myApp', [
'ui.bootstrap.tabs',
'ui.bootstrap.accordion',
'ui.bootstrap.collapse',
/*
'$strap.directives',
*/
'ui.router',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]);
不太确定该做什么。我以为加载angular然后在一段时间后加载其他脚本会修复它,但这行不通。
您的问题是没有使用绝对url到.js文件。在每个路径前包含一个/
,它应该可以解决您的问题。例如:
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js">
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="/bower_components/angular-ui-router/release/angular-ui-router.js">
- Java脚本时间添加
- Json数据包含日期和时间格式
- 如何根据时间运行不同的脚本
- 用每小时的差值填充数组/列表-从下拉列表中给定两个时间值
- 在wordpress一定时间后更改自定义字段
- 更改angularjs中的日期-时间格式
- 将当前时间添加到我的页面上的特定部分
- 门户网站:当地时间有多有用
- 显示时间的脚本
- 引导下拉列表只工作一半的时间
- Phantom JS:第一个孩子返回正确结果的时间有一半
- Javascript加载功能只能在一半的时间内工作(Firefox)
- 如何在一半时间使用javascript完成在线考试时显示警告框
- Angular.js只加载一半的时间
- 零位板的工作时间有一半
- 为什么ngDraggable在angular ng-repeat中只工作一半的时间?
- 获得空白图像与画布绘制大约一半的时间
- shadowbox.js不起作用,只在一半时间内正常打开
- 为什么游戏时间缩短了一半而不是2秒
- HTML 表只加载 jQuery 一半的时间