-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathangularModule.ts
53 lines (45 loc) · 1.87 KB
/
angularModule.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { NgModule, NgModuleFactoryLoader, SystemJsNgModuleLoader } from '@angular/core';
import { UpgradeModule } from '@angular/upgrade/static';
import { BrowserModule } from '@angular/platform-browser';
import { UIRouterUpgradeModule, NgHybridStateDeclaration } from '@uirouter/angular-hybrid';
import { sampleAppModuleAngularJS } from './angularJSModule';
import { PrefsModule } from './prefs/prefs.module';
// Create a "future state" (a placeholder) for the Contacts
// Angular module which will be lazy loaded by UI-Router
export const contactsFutureState: NgHybridStateDeclaration = {
name: 'contacts.**',
url: '/contacts',
loadChildren: './contacts/contacts.module#ContactsModule',
};
export function getDialogService($injector) {
return $injector.get('DialogService');
}
export function getContactsService($injector) {
return $injector.get('Contacts');
}
// The main NgModule for the Angular portion of the hybrid app
@NgModule({
imports: [
BrowserModule,
// Provide angular upgrade capabilities
UpgradeModule,
// Provides the @uirouter/angular directives and registers
// the future state for the lazy loaded contacts module
UIRouterUpgradeModule.forRoot({ states: [contactsFutureState] }),
// The preferences feature module
PrefsModule,
],
providers: [
// Provide the SystemJsNgModuleLoader when using Angular lazy loading
{ provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader },
// Register some AngularJS services as Angular providers
{ provide: 'DialogService', deps: ['$injector'], useFactory: getDialogService },
{ provide: 'Contacts', deps: ['$injector'], useFactory: getContactsService },
]
})
export class SampleAppModuleAngular {
constructor(private upgrade: UpgradeModule) { }
ngDoBootstrap() {
this.upgrade.bootstrap(document.body, [sampleAppModuleAngularJS.name], { strictDi: true });
}
}