twitter-bootstrap 如何正确加载 AngularJS 引导模块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15959835/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I load AngularJS bootstrap module correctly?
提问by user1002563
In my Rails app, I have ui-bootstrap-0.2.0.jsin the vendor/assets/javascriptsdirectory. I have required the file in my application.jsfile.
在我的 Rails 应用程序中,我ui-bootstrap-0.2.0.js在vendor/assets/javascripts目录中。我在我的文件中需要该application.js文件。
I get an error when I specify the bootstrap as my dependency in this line, angular.module('myApp',['ui.bootstrap']);, as instructed to do here, http://angular-ui.github.io/bootstrap/
当我在此行中将引导程序指定为我的依赖项时出现错误angular.module('myApp',['ui.bootstrap']);,按照此处的说明进行操作,http://angular-ui.github.io/bootstrap/
Chrome detects a Uncaught ReferenceError: angular is not definedat this defined module:
angular.module("ui.bootstrap", ["ui.bootstrap.accordion", ...])in the ui-bootstrap-0.2.0.js.
ChromeUncaught ReferenceError: angular is not defined在这个定义的模块中检测到一个:
angular.module("ui.bootstrap", ["ui.bootstrap.accordion", ...])在ui-bootstrap-0.2.0.js.
However, angular.jscatches an error No module:ui.bootstrap. So it seems both of these javascript files cannot see eachother. Is there a solution to this?
但是,angular.js捕获错误No module:ui.bootstrap。所以这两个javascript文件似乎都看不到彼此。有针对这个的解决方法吗?
回答by jpmorin
Here is how I did it in my project:
这是我在项目中的做法:
<script type="text/javascript" src="libs/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="libs/jquery-ui-1.10.2.custom.min.js"></script>
<script type="text/javascript" src="libs/angular.min.js"></script>
<script type="text/javascript" src="libs/angular-ui.min.js"></script>
<script type="text/javascript" src="libs/angular-resource.min.js"></script>
<script type="text/javascript" src="libs/ui-bootstrap-tpls-0.2.0.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/services.js"></script>
<script type="text/javascript" src="js/directives.js"></script>
<script type="text/javascript" src="js/filters.js"></script>
<script type="text/javascript" src="js/controllers.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
And this is how I set my application module:
这就是我设置应用程序模块的方式:
var app = angular.module('myapp', ['ui.bootstrap','ngResource']);

