最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add more than one dependency module in AngularJS - Stack Overflow

programmeradmin1浏览0评论

Hi I am new to angularjs, I want to add more than one dependency module in the app.

Here is my code:

var NBModule = angular.module('NBModule', ['ui.router','ngDraggable']);

I even tried

var NBModule = angular.module('NBModule', ['ui.router'],['ngDraggable']);

and finally

var NBModule = angular.module('NBModule', ['ui.router']);
angular.injector(NBModule, ['ngDraggable']);

i am getting this error:

[$injector:modulerr] .3.5/$injector/modulerr?p0=undefined&p1=Error%…ogleapis%2Fajax%2Flibs%2Fangularjs%2F1.3.5%2Fangular.min.js%3A38%3A146)

Hi I am new to angularjs, I want to add more than one dependency module in the app.

Here is my code:

var NBModule = angular.module('NBModule', ['ui.router','ngDraggable']);

I even tried

var NBModule = angular.module('NBModule', ['ui.router'],['ngDraggable']);

and finally

var NBModule = angular.module('NBModule', ['ui.router']);
angular.injector(NBModule, ['ngDraggable']);

i am getting this error:

[$injector:modulerr] http://errors.angularjs/1.3.5/$injector/modulerr?p0=undefined&p1=Error%…ogleapis.%2Fajax%2Flibs%2Fangularjs%2F1.3.5%2Fangular.min.js%3A38%3A146)

Share Improve this question edited Jan 18, 2015 at 10:50 Uwe Keim 40.8k61 gold badges190 silver badges304 bronze badges asked Jan 18, 2015 at 10:49 praveenrajpraveenraj 7641 gold badge9 silver badges20 bronze badges 1
  • If you click the error, does it take you to a help page? Are you loading the extra modules in the head section? – Michelangelo Commented Jan 18, 2015 at 11:10
Add a ment  | 

2 Answers 2

Reset to default 6

The first option you tried is the correct one:

var NBModule = angular.module('NBModule', ['ui.router','ngDraggable']);

I'm guessing the problem is that you didn't add the script tag in the html.

you need to add:

<script src="path/to/uiRouter.js"></script>
<script src="path/to/draggable.js"></script>

You must add the script tags of these dependencies in your HTML like this:

<script src="angular.js"></script>
<script src="ui.router.js"></script>
<script src="ng-draggable.js"></script>

If that don't work, then ui-router might be depending on ng-draggable might be

发布评论

评论列表(0)

  1. 暂无评论