Ravinder Payal
Ravinder Payal

Reputation: 3031

How to inject and import dependencies at run time in angular 2

I started learning angularJS2 for my Social project. It is huge project and the app requires different activities at different stages and also a one page app. I doesn't want to load all dependencies at first time. My first screen will be login/signup after going threw these there will be screens according user's personalization which requires different dependencies. So basically how to achieve this, is my question.

Upvotes: 0

Views: 544

Answers (2)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657338

Angular is working on a build tool that results in the app only loading the components that are required for a specific route. You won't have to do anything to get this feature except using the router.

Upvotes: 2

basarat
basarat

Reputation: 275867

So basically how to achieve this

You are looking for lazy loading.

This is a topic covered well here : http://blog.mgechev.com/2015/09/30/lazy-loading-components-routes-services-router-angular-2/

Upvotes: 3

Related Questions