Last active
April 6, 2018 15:16
-
-
Save kmaraz/cc422f7c104a6054cb2845c396e8a0cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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