0

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.

Dinistro
  • 5,701
  • 1
  • 30
  • 38
Ravinder Payal
  • 2,884
  • 31
  • 40
  • [possibly of interest](http://stackoverflow.com/questions/34489916/load-external-js-script-dynamically-in-angular-2/34489991) – drew moore May 12 '16 at 05:56
  • yes it is of my interest but i doesn't know how that can solve my problem I will read that twice thrice ...thanks – Ravinder Payal May 12 '16 at 06:08
  • 2
    np - but frankly, I doubt it's going to be very helpful for what you're doing. As I said, I just thought it might be of interest... @GünterZöchbauer is correct that framework support for this will be landing in a future RC, and you're almost-certainly going to want to abandon whatever you do now in favor of using that once it's there, so don't waste too much time. – drew moore May 12 '16 at 06:16

2 Answers2

3

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/

basarat
  • 261,912
  • 58
  • 460
  • 511
2

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.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • I don't know. It was mentioned in a talk at ng-conf. They built a new router from scratch very recently because the "old" one introduced some limitations for lazy loading. I guess it will still take a few months until it will be available and stable. – Günter Zöchbauer May 12 '16 at 05:55
  • ok will that be supporting multiple views or again we have to use third party like angular-ui router – Ravinder Payal May 12 '16 at 05:57
  • What do you mean by "multiple views"? I guess multiple ``s. This also was limited in the "old" router and now allows multiple ``s at every level. – Günter Zöchbauer May 12 '16 at 05:58
  • multiple view means state based loading like... if i loaded a page say index now i want a view inside that index page which can load either login screen or signup screen but not together instead based on rout like `index/login` and `index/signup` and when user directly access any of them the index page should be loaded automatically and then login or signup screen inside that – Ravinder Payal May 12 '16 at 06:06
  • I see. I don't know. I guess we have to wait until it becomes available. – Günter Zöchbauer May 12 '16 at 06:09