-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-routing.module.ts
70 lines (61 loc) · 2.36 KB
/
app-routing.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { ServerResolverService } from './services/server-resolver.service';
import { ErrorMessageComponent } from './error-message/error-message.component';
import { CanDeactivateGuard } from './services/canDeactivate-guard.service';
import { CanDeactivate } from '@angular/router/router';
import { AuthGuardService } from './services/auth-guard.service';
import { Routes, RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
import { EditServerComponent } from './servers/edit-server/edit-server.component';
import { ServerComponent } from './servers/server/server.component';
import { ServersComponent } from './servers/servers.component';
import { UserComponent } from './users/user/user.component';
import { UsersComponent } from './users/users.component';
import { HomeComponent } from './home/home.component';
const appRoutes: Routes = [
{
path: "", component: HomeComponent, pathMatch: 'full'
},
{
path: "users", component: UsersComponent, children: [
{
path: ":id/:name", component: UserComponent
},
]
},
{
path: "servers", canActivateChild: [AuthGuardService], component: ServersComponent, children: [
{
path: ":id", component: ServerComponent, resolve: {server: ServerResolverService}
},
{
path: ":id/edit", component: EditServerComponent, canDeactivate: [CanDeactivateGuard]
}
]
},
// {
// path: '404-NotFound', component: PageNotFoundComponent
// },
{
path: "404-NotFound", component: ErrorMessageComponent, data: {errorMessage: "404 Error on this page"}
},
{
path: '**', redirectTo: '404-NotFound'
}
]
@NgModule({
imports: [
//RouterModule.forRoot(appRoutes, {useHash: true})
RouterModule.forRoot(appRoutes)
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
// Here we add all our routes and of course bring in the imports
// Remember to import RouterModule and export it through app.modules exports section
// where you declare this class
// NB... canActivateChild: [AuthGuardService] and canDeactivate: [CanDeactivateGuard] these are
// services which set up checks for auth-guard and deactivate before saving
//useHash is an option in older browser. Not a recommened feature unless issues with //server