Home load angularjs module only if available
Reply: 1

load angularjs module only if available

Deekshith S
1#
Deekshith S Published in 2018-01-13 05:52:56Z

I want to load my sub angularjs module only if it available, I am adding subApp module but if subApp not found then my mainApp module also stop working.

I have searched for this in stack overflow, but I did not get any perfect solution to my problem.

var mainkApp = angular.module('mainApp',['subApp']);

this is my code please give me a solution to my subApp module will load only if exist, thanks

Tek chand choudhary
2#
Tek chand choudhary Reply to 2018-01-13 18:52:21Z

You can lazy load a module when it is needed by using ui-router's lazyLoad property on a state definition.

var mystate = {
  name: 'messages',
  url: '/messages',
  component: messages,
  lazyLoad: function() {
    return System.import('moment');
  }
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306768 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO