Skip to content

Commit 0270607

Browse files
committed
Moving User/kycForm and Polls module as LAZY Feature module
Moving User/kycForm and Polls module as LAZY Feature module
1 parent 7ea9f24 commit 0270607

File tree

8 files changed

+98
-36
lines changed

8 files changed

+98
-36
lines changed

angular-playground/pollingApp/src/app/app-poll/app-poll.module.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,29 @@ import { AppPollData } from './app-poll.data';
1111
import { AppPollComponent } from './app-poll.component';
1212
import { AppPollListComponent} from './app-poll-list.component';
1313
import { BrowserModule } from '@angular/platform-browser';
14-
15-
// import { ProductListComponent } from './product-list.component';
16-
// import { ProductDetailComponent } from './product-detail.component';
17-
// import { ProductEditComponent } from './product-edit.component';
18-
// import { ProductEditGuard } from './product-edit.guard';
19-
14+
import { SharedModule } from 'src/app/shared/shared.module';
15+
import { HttpModule } from '@angular/http';
16+
import { AppPollService } from 'src/app/app-poll/app-poll.service';
17+
2018
@NgModule({
2119
imports: [
22-
BrowserModule,
20+
SharedModule,HttpModule,
2321
HttpClientModule,
2422
ChartModule,
2523
InMemoryWebApiModule.forRoot(AppPollData),
2624
RouterModule.forChild([
27-
{ path: 'polls', component: AppPollListComponent },
28-
{ path: 'polls/:id', component: AppPollComponent },
25+
{ path: '', component: AppPollListComponent },
2926
{
30-
path: 'polls/:id/edit',
27+
path: ':id/edit',
3128
//canDeactivate: [ProductEditGuard],
3229
component: AppPollComponent
3330
}
3431
])
3532
],
3633
declarations: [
3734
AppPollComponent,
38-
AppPollListComponent,
39-
// ProductDetailComponent,
40-
// ProductEditComponent
41-
]
35+
AppPollListComponent,
36+
],
37+
providers:[AppPollService]
4238
})
4339
export class AppPollModule { }

angular-playground/pollingApp/src/app/app-routing.module.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
3-
import { AppPollComponent } from './app-poll/app-poll.component';
4-
import { KycFormComponent } from './user/kyc-form.component';
53

6-
const routes: Routes = [
7-
{path: 'welcome', component: AppPollComponent},
8-
//{path: '**', redirectTo: "welcome", pathMatch: "full"},
9-
{path:'', redirectTo: "welcome", pathMatch: "full"},
10-
{path: 'kycform', component: KycFormComponent},
4+
import { AppComponent } from 'src/app/app.component';
5+
import { ShellComponent } from 'src/app/home/shell.component';
6+
import { PageNotFoundComponent } from 'src/app/home/page-not-found.component';
7+
import { WelcomeComponent } from 'src/app/home/welcome.component';
8+
import { AuthGuard } from 'src/app/user/auth-guard.service';
9+
import { LoginComponent } from 'src/app/user/login.component';
1110

11+
const routes: Routes = [
12+
{
13+
path: '',
14+
component: ShellComponent,
15+
children: [
16+
{ path: 'welcome', component: WelcomeComponent },
17+
{
18+
path: 'polls',
19+
canActivate: [AuthGuard],
20+
loadChildren: './app-poll/app-poll.module#AppPollModule'
21+
},
22+
{ path: 'kycform', loadChildren:'./user/user.module#UserModule'},
23+
{ path: '', redirectTo: 'welcome', pathMatch: 'full' },
24+
]
25+
},
26+
{ path: '**', component: PageNotFoundComponent }
1227
];
1328

1429
@NgModule({

angular-playground/pollingApp/src/app/app.module.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { NgModule } from '@angular/core';
33
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
44
import { ReactiveFormsModule } from '@angular/forms';
55

6-
import { ButtonModule, DropdownModule, PanelModule, ProgressBarModule } from 'primeng/primeng';
6+
7+
//import { ButtonModule, DropdownModule, PanelModule, ProgressBarModule } from 'primeng/primeng';
78

89
import { from } from 'rxjs/internal/observable/from';
910

@@ -13,24 +14,24 @@ import { AppPollModule } from 'src/app/app-poll/app-poll.module';
1314
import { AppRoutingModule } from './app-routing.module';
1415

1516
import { AppComponent } from './app.component';
16-
import { KycFormComponent } from './user/kyc-form.component';
17+
//import { KycFormComponent } from './user/kyc-form.component';
1718
import { MenuComponent } from './home/menu.component';
19+
import { WelcomeComponent } from './home/welcome.component';
20+
import { ShellComponent } from 'src/app/home/shell.component';
21+
import { PageNotFoundComponent } from 'src/app/home/page-not-found.component';
1822

1923
@NgModule({
2024
declarations: [
21-
AppComponent,
22-
KycFormComponent,
23-
MenuComponent,
25+
AppComponent,
26+
MenuComponent, WelcomeComponent,ShellComponent, PageNotFoundComponent
2427
],
2528
imports: [
2629
BrowserModule,
2730
BrowserAnimationsModule,
2831
ReactiveFormsModule,
29-
ProgressBarModule,
30-
AppRoutingModule,
31-
AppPollModule,
32-
UserModule
33-
],
32+
33+
AppRoutingModule
34+
],
3435
providers: [],
3536
bootstrap: [AppComponent]
3637
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
template: `
5+
<h1>This is not the page you were looking for!</h1>
6+
`
7+
})
8+
export class PageNotFoundComponent { }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<app-menu></app-menu>
2+
3+
<div class='container main-content'>
4+
<router-outlet></router-outlet>
5+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-shell',
5+
templateUrl: './shell.component.html',
6+
styleUrls: ['./shell.component.less']
7+
//, changeDetection: ChangeDetectionStrategy.OnPush
8+
})
9+
export class ShellComponent implements OnInit {
10+
11+
constructor() { }
12+
13+
ngOnInit() {
14+
}
15+
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4+
import { BrowserModule } from '@angular/platform-browser';
5+
6+
@NgModule({
7+
imports: [
8+
CommonModule
9+
],
10+
exports: [
11+
CommonModule,
12+
FormsModule,
13+
ReactiveFormsModule
14+
]
15+
})
16+
export class SharedModule { }

angular-playground/pollingApp/src/app/user/user.module.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ import { LoginComponent } from './login.component';
44
import { FormsModule } from '@angular/forms';
55
import { BrowserModule } from '@angular/platform-browser';
66
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7+
import { KycFormComponent } from 'src/app/user/kyc-form.component';
8+
import { SharedModule } from 'src/app/shared/shared.module';
9+
10+
import { ButtonModule, DropdownModule, PanelModule, ProgressBarModule } from 'primeng/primeng';
711

812
const userRoutes: Routes = [
9-
{path: 'login', component: LoginComponent}
13+
{path: 'login', component: LoginComponent},
14+
{path: '', component: KycFormComponent}
15+
1016
];
1117

1218
@NgModule({
13-
declarations:[LoginComponent],
19+
declarations:[LoginComponent, KycFormComponent],
1420
imports:[
15-
BrowserModule,
16-
BrowserAnimationsModule,
17-
FormsModule,
21+
ProgressBarModule,
22+
SharedModule,
1823
RouterModule.forChild(userRoutes)
1924
],
2025
providers:[]

0 commit comments

Comments
 (0)