简体   繁体   中英

How to add more than one dependency module in AngularJS

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.org/1.3.5/ $injector/modulerr?p0=undefined&p1=Error%…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.5%2Fangular.min.js%3A38%3A146)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM