Browse Source

21-274 Lazy loading recipes module

tags/before_ngrx
Nils Dittberner 8 years ago
parent
commit
8d8ee6dcd9
6 changed files with 29 additions and 11 deletions
  1. +3
    -1
      src/app/app-routing.module.ts
  2. +9
    -9
      src/app/app.module.ts
  3. +0
    -0
      src/app/home/home.component.css
  4. +1
    -0
      src/app/home/home.component.html
  5. +15
    -0
      src/app/home/home.component.ts
  6. +1
    -1
      src/app/recipes/recipes-routing.module.ts

+ 3
- 1
src/app/app-routing.module.ts View File

@@ -2,9 +2,11 @@ import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'

import { ShoppingListComponent } from './shopping-list/shopping-list.component';
import { HomeComponent } from './home/home.component';

const appRoutes: Routes = [
{ path: '', redirectTo: '/recipes', pathMatch: 'full' },
{ path: '', component: HomeComponent },
{ path: 'recipes', loadChildren: './recipes/recipes.module#RecipesModule'},
{ path: 'shopping-list', component: ShoppingListComponent }
];



+ 9
- 9
src/app/app.module.ts View File

@@ -4,29 +4,29 @@ import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';

import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { ShoppingListService } from './shopping-list/shopping-list.service';
import { AppRoutingModule } from './app-routing.module';
import { RecipeService } from './recipes/recipe.service';
import { DataStorageService } from './shared/data-storage.service';
import { AuthService } from './auth/auth.service';
import { AuthGuard } from './auth/auth-guard.service';
import { RecipesModule } from './recipes/recipes.module';
import { AuthModule } from './auth/auth.module';
import { AuthService } from './auth/auth.service';
import { DataStorageService } from './shared/data-storage.service';
import { HeaderComponent } from './header/header.component';
import { RecipeService } from './recipes/recipe.service';
import { SharedModule } from './shared/shared.module';
import { ShoppingListModule } from './shopping-list/shopping-list.module';
import { AuthModule } from './auth/auth.module';
import { ShoppingListService } from './shopping-list/shopping-list.service';
import { HomeComponent } from './home/home.component';

@NgModule({
declarations: [
AppComponent,
HeaderComponent
HeaderComponent,
HomeComponent
],
imports: [
BrowserModule,
HttpClientModule,
HttpModule,
AppRoutingModule,
RecipesModule,
SharedModule,
ShoppingListModule,
AuthModule


+ 0
- 0
src/app/home/home.component.css View File


+ 1
- 0
src/app/home/home.component.html View File

@@ -0,0 +1 @@
<h2>Welcome to the Recipe Book</h2>

+ 15
- 0
src/app/home/home.component.ts View File

@@ -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() {
}

}

+ 1
- 1
src/app/recipes/recipes-routing.module.ts View File

@@ -8,7 +8,7 @@ import { RecipeDetailComponent } from './recipe-detail/recipe-detail.component';
import { AuthGuard } from '../auth/auth-guard.service';

const recipesRoutes: Routes = [
{ path: 'recipes' , component: RecipesComponent, children: [
{ path: '' , component: RecipesComponent, children: [
{ path: '', component: RecipeStartComponent },
{ path: 'new', component: RecipeEditComponent, canActivate: [AuthGuard] },
{ path: ':id', component: RecipeDetailComponent },


Loading…
Cancel
Save