Skip to content

docs: update README to reflect route generation changes #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 7 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
```

By default the cli will add the import statements for HeroList and HeroDetail to
`hero-root.component.ts`:

```
@RouteConfig([
{path:'/', name: 'HeroList', component: HeroListComponent, useAsDefault: true},
{path:'/:id', name: 'HeroDetail', component: HeroDetailComponent}
])
```

The generated `route-config.ts` file is also updated with the following:
The generated route will also be registered with the parent component's `@RouteConfig` decorator.

```
// 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}
];
```
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.

Visiting `http://localhost:4200/hero` will show the hero list.
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 default lazy nature of routes can be turned off via the lazy flag (`--lazy false`)

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

Expand Down