0

I need a third party module in my angular app for the specific page only so i dont want to load those js files when they are not required

currently code is like this

angular.module('app', ['othermodule']);

but i want it like

angular.module('app',['']).
controller('ctrl'['module',function(module){

}]);

or any similar alternatives. How can modules be loaded conditionally ?

Ajeet Lakhani
  • 3,768
  • 2
  • 22
  • 37
  • [Developing an AngularJS app with dynamic set of modules](http://stackoverflow.com/questions/16806901/developing-an-angularjs-app-with-dynamic-set-of-modules?rq=1) ? – pdenes Aug 08 '15 at 17:10

1 Answers1

0

The first thing you will need to do is break your angular modules out into their own files. A simple example would be a seperate app.js that handles creating the app and routing, then controller.js and factory.js. Once you have a seperate file for each module you create the module with this syntax

angular.module('myapp.functionName.type',  ['inject your custom module here'])
.whatever (controller, value, factory, etc) 

You would then inject the myapp.functionName.type into the app.js

tuckerjt07
  • 902
  • 1
  • 12
  • 31
  • i think you didnt undertand my question. I am already doing that. So for `angular.module('myapp.functionName.type', ['inject your custom module here'])`. you need to load custom modules along with main app. I want to load these custom module condtionally. – Ajeet Lakhani Aug 10 '15 at 23:55