-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.module.ts
42 lines (36 loc) · 1.2 KB
/
app.module.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
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {RouterModule, Route,Routes, PreloadingStrategy} from '@angular/router';
import { HttpModule } from '@angular/http';
import { MailModule } from './mail/mail.module';
import { AppComponent } from './app.component';
import {Observable} from "rxjs/Observable";
import 'rxjs/add/observable/of';
import {AuthGuard} from "./auth/auth.guard";
import {AuthModule} from "./auth/auth.module";
export class CustomPreload implements PreloadingStrategy {
preload(route: Route, fn: () => Observable<any>): Observable<any> {
return route.data && route.data.preload ? fn() : Observable.of(null)
}
}
export const ROUTES: Routes = [
{ path: 'dashboard', canLoad:[AuthGuard], data: {preload: CustomPreload}, loadChildren: './dashboard/dashboard.module#DashboardModule' },
{ path: '**', redirectTo: 'mail/folder/inbox' }
];
@NgModule({
declarations: [
AppComponent
],
providers: [CustomPreload],
imports: [
BrowserModule,
HttpModule,
MailModule,
AuthModule,
RouterModule.forRoot(ROUTES, {preloadingStrategy: CustomPreload})
],
bootstrap: [
AppComponent
]
})
export class AppModule {}