Skip to content

Commit d5cccd5

Browse files
author
Gregor Woiwode
committed
Updates routes snippet
1 parent df65e52 commit d5cccd5

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,14 @@ export class <PipeName>Pipe implements PipeTransform {
120120
`ng2-routes` creates the `@Routes` decorator with a single route in it.
121121

122122
```ts
123-
@Routes([
124-
{ path: '/<route>', component: <component-name> }
125-
])
123+
import { RouterModule, Routes } from '@angular/router';
124+
125+
const app_routes: Routes = [
126+
{ path: '<url-segment>', component: <component-name> },
127+
{ path: '**', pathMatch: 'full', redirectTo: '<url-segment>' }
128+
];
129+
130+
export const app_routing = RouterModule.forRoot(app_routes);
126131
```
127132

128133
### ng2-route-path

snippets/typescript.cson

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@
6868
'description': 'Angular 2 route config snippet'
6969
'descriptionMoreURL': 'https://angular.io/docs/ts/latest/api/router/Route-class.html'
7070
'body': """
71-
@Routes([
72-
{ path: '/${1:path}', component: ${2:component} }$3
73-
])
71+
import { RouterModule, Routes } from '@angular/router';
72+
73+
const app_routes: Routes = [
74+
{ path: '${1:routePath}', component: ${2:Component} },
75+
{ path: '**', pathMatch: 'full', redirectTo: '$1' }
76+
];
77+
78+
export const app_routing = RouterModule.forRoot(app_routes);
79+
$3
7480
"""
7581
'Angular Route Definition':
7682
'prefix': 'ng2-route-path'

0 commit comments

Comments
 (0)