-
Notifications
You must be signed in to change notification settings - Fork 146
/
SharedModule.ts
31 lines (30 loc) · 973 Bytes
/
SharedModule.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
import {
NgModule,
ModuleWithProviders
} from "@angular/core";
import {CommonModule} from "@angular/common";
import {
FormsModule,
ReactiveFormsModule
} from "@angular/forms";
import {AuthService} from "../../../services/AuthService";
import {
HttpModule,
JsonpModule
} from "@angular/http";
import {CommBroker} from "../../../services/CommBroker";
@NgModule({
imports: [CommonModule, FormsModule, HttpModule, JsonpModule, ReactiveFormsModule],
declarations: [],
exports: [CommonModule, FormsModule, HttpModule, JsonpModule, ReactiveFormsModule]
})
// here we are loading the AuthService ONLY when this shared module is loaded by the app and not
// by a feature or lazy loaded module, this making sure we share a single instance of AuthService
export class SharedModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SharedModule,
providers: [AuthService, CommBroker]
};
}
}