Skip to content

Instantly share code, notes, and snippets.

@kmaraz
Last active April 6, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmaraz/cc422f7c104a6054cb2845c396e8a0cc to your computer and use it in GitHub Desktop.
Save kmaraz/cc422f7c104a6054cb2845c396e8a0cc to your computer and use it in GitHub Desktop.
// The original AngularJs application
const ngModule = angular.module('admin', [
// We are leaving all the old module untouched
'ng1.modules',
// We can downgrade Components, Directives, Services, etc.
// And use them in the AngularJs app
'ng2.modules'
]);
@NgModule({
imports: [
BrowserModule,
UpgradeModule,
// Import Store and Effects module
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
],
providers: [
// Import meta-reducers
{
provide: META_REDUCERS,
useFactory: fromRootReducers.getMetaReducers
},
// Import Effects as Injectables
...fromRootEffects.getEffectProviders(),
]
})
class AppModule {
constructor(
private upgrade: UpgradeModule,
private injector: Injector
) { }
ngDoBootstrap() {
// Bootstrap main app
this.upgrade.bootstrap(document.body, ['admin']);
// Register effects (this is necessary in the hybrid app)
const effectClasses = this.injector.get(fromRootEffects.EFFECTS_CLASS);
for (const effectClass of effectClasses) {
effectClass.ngRegisterEffects();
}
}
}
platformBrowserDynamic().bootstrapModule(AppModule);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment