0

I have a web application into which another widget should be integrated. The widget script is loaded asynchronously and takes around 10 sec to load.I want to add this widget module as a dependency in my angular application after the relevant scripts are loaded. Is this actually feasible? I am using ng-app to bootstrap my application.In another comment, I found that dynamic injection of modules is possible only before bootstraping the application.Is there any workaround for this or is this bad approach altogether?

Edit: The application should not be dependent on the loading of widget since it is only an integration.As many people have suggested, when i use requireJS,it forces the bootstrap of application to wait till the widget loads. Is there any way to handle this?

asked Feb 23, 2016 at 7:00
4
  • Have you checked out require.js? Commented Feb 23, 2016 at 7:08
  • stackoverflow.com/questions/12758157/… have you seen this? Commented Feb 23, 2016 at 7:08
  • The question you mentioned deals with injecting a service into my controller. I want to add a new dependency module into my angular application. Commented Feb 23, 2016 at 7:11
  • @SatejS require.js is an option but one should have better understanding of both Angular and Require before using them together, Here is another option for lazy loading ify.io/lazy-loading-in-angularjs Commented Feb 23, 2016 at 7:18

1 Answer 1

0

If you can bear requirejs with angularjs then angularAMD is the option:

AngularJS + RequireJS: The Proper and Easier Way

If you choose to go with direct option:

Lazy Loading In AngularJS

answered Feb 23, 2016 at 7:23
Sign up to request clarification or add additional context in comments.

3 Comments

As mentioned in the comment to the question, this deals with lazy loading of controllers,services etc in a module. I need to load a dependency module.Is it totally different or am i missing something?
Its samething you just need to put some time on the links provided, so that you have better understanding of task and its accomplishment. Its same what you need.
The above approaches make the application dependent on widget module (bootstraping after the module loads). However, the application should not be dependent on the widget. Ideally, even if the widget fails to load, the app should be up and running

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.