Skip to content

Commit 4e1c4f8

Browse files
routing module
1 parent 314115e commit 4e1c4f8

File tree

4 files changed

+52
-18
lines changed

4 files changed

+52
-18
lines changed

src/app/app-routing.module.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule, Routes } from '@angular/router';
3+
4+
import { LoginComponent } from './login/login.component';
5+
import { DashboardComponent } from './dashboard/dashboard.component';
6+
7+
import { AuthService } from './services/auth.service';
8+
9+
const routes: Routes = [
10+
{
11+
path: '',
12+
redirectTo: 'login',
13+
pathMatch: 'full'
14+
},
15+
{
16+
path: 'login',
17+
component: LoginComponent
18+
},
19+
{
20+
path: 'dashboard',
21+
component: DashboardComponent,
22+
canActivate: [ AuthService ]
23+
}
24+
];
25+
26+
@NgModule({
27+
imports: [
28+
RouterModule.forRoot(routes)
29+
],
30+
exports: [
31+
RouterModule
32+
]
33+
})
34+
export class AppRoutingModule { }

src/app/app.module.ts

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
33
import { ReactiveFormsModule } from '@angular/forms';
4-
import { RouterModule, Routes } from '@angular/router';
54
import { HttpClientModule } from '@angular/common/http';
65

76
import { AppComponent } from './app.component';
@@ -11,23 +10,8 @@ import { HeaderComponent } from './header/header.component';
1110
import { FooterComponent } from './footer/footer.component';
1211

1312
import { AuthService } from './services/auth.service';
13+
import { AppRoutingModule } from './app-routing.module';
1414

15-
const routes: Routes = [
16-
{
17-
path: '',
18-
redirectTo: 'login',
19-
pathMatch: 'full'
20-
},
21-
{
22-
path: 'login',
23-
component: LoginComponent
24-
},
25-
{
26-
path: 'dashboard',
27-
component: DashboardComponent,
28-
canActivate: [ AuthService ]
29-
}
30-
];
3115

3216
@NgModule({
3317
declarations: [
@@ -41,7 +25,7 @@ const routes: Routes = [
4125
BrowserModule,
4226
HttpClientModule,
4327
ReactiveFormsModule,
44-
RouterModule.forRoot(routes)
28+
AppRoutingModule
4529
],
4630
providers: [AuthService],
4731
bootstrap: [AppComponent]

src/configs/dev.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mysql": {
3+
"host" : "localhost",
4+
"user" : "root",
5+
"password" : "root",
6+
"database" : "angular5-admin"
7+
}
8+
}

src/configs/prod.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mysql": {
3+
"host" : "localhost",
4+
"user" : "root",
5+
"password" : "root",
6+
"database" : "angular5-admin"
7+
}
8+
}

0 commit comments

Comments
 (0)