Skip to content

Commit f7fa577

Browse files
committed
Module 13: Angular Modules.
1 parent efee47f commit f7fa577

File tree

3 files changed

+48
-17
lines changed

3 files changed

+48
-17
lines changed

APM/src/app/app.module.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
3-
import { FormsModule} from '@angular/forms';
43
import { HttpClientModule } from '@angular/common/http';
54
import { RouterModule } from '@angular/router';
65

76
import { AppComponent } from './app.component';
8-
import { ProductListComponent } from './products/product-list.component';
9-
import { ConvertToSpacesPipe } from './shared/convert-to-spaces.pipe';
10-
import { StarComponent } from './shared/star.component';
11-
import { ProductDetailComponent } from './products/product-detail.component';
127
import { WelcomeComponent } from './home/welcome.component';
13-
import { ProductDetailGuard } from './products/product-detail.guard';
8+
import { ProductModule } from './products/product.module';
149

1510
@NgModule({
1611
declarations: [
1712
AppComponent,
18-
ProductListComponent,
19-
ConvertToSpacesPipe,
20-
StarComponent,
21-
ProductDetailComponent,
2213
WelcomeComponent,
2314
],
2415
imports: [
2516
BrowserModule,
26-
FormsModule,
2717
HttpClientModule,
2818
RouterModule.forRoot([
29-
{ path: 'products', component: ProductListComponent },
30-
{
31-
path: 'products/:id',
32-
canActivate: [ProductDetailGuard],
33-
component: ProductDetailComponent
34-
},
3519
{ path: 'welcome', component: WelcomeComponent },
3620
{ path: '', redirectTo: 'welcome', pathMatch: 'full' },
3721
{ path: '**', redirectTo: 'welcome', pathMatch: 'full'},
3822
]),
23+
ProductModule,
3924
],
4025
bootstrap: [AppComponent]
4126
})
27+
4228
export class AppModule { }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { NgModule } from '@angular/core';
2+
import { ProductListComponent } from './product-list.component';
3+
import { ProductDetailComponent } from './product-detail.component';
4+
import { ConvertToSpacesPipe } from '../shared/convert-to-spaces.pipe';
5+
import { RouterModule } from '@angular/router';
6+
import { ProductDetailGuard } from './product-detail.guard';
7+
import { SharedModule } from '../shared/shared.module';
8+
9+
@NgModule({
10+
declarations: [
11+
ProductListComponent,
12+
ProductDetailComponent,
13+
ConvertToSpacesPipe,
14+
],
15+
imports: [
16+
RouterModule.forChild([
17+
{ path: 'products', component: ProductListComponent },
18+
{
19+
path: 'products/:id',
20+
canActivate: [ProductDetailGuard],
21+
component: ProductDetailComponent
22+
},
23+
]),
24+
SharedModule,
25+
]
26+
})
27+
28+
export class ProductModule { }

APM/src/app/shared/shared.module.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { StarComponent } from './star.component';
4+
import { FormsModule } from '@angular/forms';
5+
6+
@NgModule({
7+
declarations: [StarComponent],
8+
imports: [
9+
CommonModule,
10+
],
11+
exports: [
12+
StarComponent,
13+
CommonModule,
14+
FormsModule,
15+
]
16+
})
17+
export class SharedModule { }

0 commit comments

Comments
 (0)