From fdae6c7c81cf91ea06efafd915ece6605e6535a3 Mon Sep 17 00:00:00 2001 From: Mike Brocchi Date: Tue, 19 Apr 2016 10:33:52 -0400 Subject: [PATCH] docs: update README to reflect route generation changes (#458) --- README.md | 53 +++++++---------------------------------------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index befa45fe8f..479997069e 100644 --- a/README.md +++ b/README.md @@ -99,57 +99,18 @@ used in `hero`): ng generate route hero ``` -This will create a folder with a routable component (`hero-root.component.ts`) -with two sub-routes. The file structure will be as follows: +This will create a folder which will contain the hero component and related test and style files. -``` -... -|-- app -| |-- hero -| | |-- hero-detail.component.html -| | |-- hero-detail.component.css -| | |-- hero-detail.component.spec.ts -| | |-- hero-detail.component.ts -| | |-- hero-list.component.html -| | |-- hero-list.component.css -| | |-- hero-list.component.spec.ts -| | |-- hero-list.component.ts -| | |-- hero-root.component.spec.ts -| | |-- hero-root.component.ts -| | |-- hero.service.spec.ts -| | |-- hero.service.ts -| |-- ... -|-- app.ts -|-- route-config.ts -... -``` +The generated route will also be registered with the parent component's `@RouteConfig` decorator. -By default the cli will add the import statements for HeroList and HeroDetail to -`hero-root.component.ts`: +By default the route will be designated as a **lazy** route which means that it will be loaded into the browser when needed, not upfront as part of a bundle. -``` -@RouteConfig([ - {path:'/', name: 'HeroList', component: HeroListComponent, useAsDefault: true}, - {path:'/:id', name: 'HeroDetail', component: HeroDetailComponent} -]) -``` +In order to visually distinguish lazy routes from other routes the folder for the route will be prefixed with a `+` per the above example the folder will be named `+hero`. +This is done in accordance with the style guide. -The generated `route-config.ts` file is also updated with the following: +The default lazy nature of routes can be turned off via the lazy flag (`--lazy false`) -``` -// DO NOT EDIT THIS FILE -// IT IS AUTO GENERATED BY ANGULAR-CLI -import {HeroRoot} from './hero/hero-root.component'; - -export const CliRouteConfig = [ - {path:'/hero/...', name: 'HeroRoot', component: HeroRoot} -]; -``` - -Visiting `http://localhost:4200/hero` will show the hero list. - - -There is an optional flag for `skip-router-generation` which will not add the route to the `CliRouteConfig` for the application. +There is an optional flag for `skip-router-generation` which will not add the route to the parent component's `@RouteConfig` decorator. ### Creating a build