Is it possible to load an ng2 + app manually from javascript?

Is it possible to load NG2 + app manually from jquery / javascript code?

I need something like TypeScript:

platformBrowserDynamic().bootstrapModule(AppModule);

      

+3


source to share


1 answer


The situation is approaching from the wrong end.

To do this, platformBrowserDynamic

and AppModule

should be open to the global scope, but it is not. While it is possible to load Angular as UMD modules and have it as ng

global, this will result in 2 copies of Angular and AppModule

not available.

This is possible by exposing the function to the global scope:



window.bootstrapApp = () => platformBrowserDynamic().bootstrapModule(AppModule);

      

But given that the goal is to quickly validate users' rights with Angular code, the right place to do this is still main.ts

. And the preferred way to defer application initialization is to check the checks on the download with the APP_INITIALIZER

provider
.

+3


source







All Articles