Skip to content

Commit

Permalink
add lazy load route example
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad committed Oct 28, 2017
1 parent 7f13bb0 commit 5c2e355
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';

Expand All @@ -8,7 +9,10 @@ import { AppComponent } from './app.component';
AppComponent
],
imports: [
BrowserModule
BrowserModule,
RouterModule.forRoot([{
path: '', loadChildren: './home/home.module#HomeModule'
}])
],
providers: [],
bootstrap: [AppComponent]
Expand Down
Empty file added src/app/home/home.component.css
Empty file.
3 changes: 3 additions & 0 deletions src/app/home/home.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
home works!
</p>
15 changes: 15 additions & 0 deletions src/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
20 changes: 20 additions & 0 deletions src/app/home/home.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { HomeComponent } from './home.component';

@NgModule({
declarations: [
HomeComponent
],
imports: [
CommonModule,
RouterModule.forChild([{
path: '', component: HomeComponent
}])
],
providers: [],
bootstrap: [HomeComponent]
})
export class HomeModule { }
2 changes: 1 addition & 1 deletion src/ui-select/ui-select.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TEST
<router-outlet></router-outlet>

0 comments on commit 5c2e355

Please sign in to comment.