Considering the new changes that came out with the new RC I'm a bit lost at how I should approach this problem.
I have a .json file containing the name and path for the components I want to dinamically load. I can change the structure of this file if needed :
Example:
[
{"component": "Comp1", "path": "./comp1.js"},
{"component": "Comp2", "path": "./comp2.js"}
]
Until now I've used to load the JSON, System import the js files, save them in an array and simply reset the router config. Here's a really old and outdated version but the principle is the same: http://embed.plnkr.co/jAmMZKz2VqponmFtPpes/
I'm also interested in having those components lazy load. No clue on how to do that yet.
Now the ideas that came to my mind on how I could do this:
Get the json before bootstraping and pass it to the router. Would prefer not doing this since it isn't really "the angular2 way".
Doing a
LoadNextToContent
every time the user requires a dynamically loaded component and removing it when he is done using it.
Are there easier ways to do this? Better ways performance wise?