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 ?

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.