From da58ff45c7896d2f883c751bbd1d520009c6a3c5 Mon Sep 17 00:00:00 2001 From: Foxandxss Date: Tue, 5 Jul 2016 15:06:13 +0200 Subject: [PATCH] docs(style-guide): update style-guide samples to use v3 router closes #1828 --- .../style-guide/ts/app/app.component.ts | 58 +----------------- .../style-guide/ts/app/app.routes.ts | 61 +++++++++++++++++++ .../docs/_examples/style-guide/ts/app/main.ts | 4 +- 3 files changed, 64 insertions(+), 59 deletions(-) create mode 100644 public/docs/_examples/style-guide/ts/app/app.routes.ts diff --git a/public/docs/_examples/style-guide/ts/app/app.component.ts b/public/docs/_examples/style-guide/ts/app/app.component.ts index 27287bfd7c..d90494c212 100644 --- a/public/docs/_examples/style-guide/ts/app/app.component.ts +++ b/public/docs/_examples/style-guide/ts/app/app.component.ts @@ -1,65 +1,9 @@ import { Component } from '@angular/core'; -import { RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; - -import { AppComponent as S0101 } from '../01-01/app'; -import { AppComponent as S0207 } from '../02-07/app'; -import { AppComponent as S0208 } from '../02-08/app'; -import { AppComponent as S0301 } from '../03-01/app'; -import { AppComponent as S0302 } from '../03-02/app'; -import { AppComponent as S0303 } from '../03-03/app'; -import { AppComponent as S0304 } from '../03-04/app'; -import { AppComponent as S0305 } from '../03-05/app'; -import { AppComponent as S0306 } from '../03-06/app'; -import { AppComponent as S0410 } from '../04-10/app'; -import { AppComponent as S0414 } from '../04-14/app'; -import { AppComponent as S0502 } from '../05-02/app'; -import { AppComponent as S0503 } from '../05-03/app'; -import { AppComponent as S0504 } from '../05-04/app'; -import { AppComponent as S0512 } from '../05-12/app'; -import { AppComponent as S0513 } from '../05-13/app'; -import { AppComponent as S0514 } from '../05-14/app'; -import { AppComponent as S0515 } from '../05-15/app'; -import { AppComponent as S0516 } from '../05-16/app'; -import { AppComponent as S0517 } from '../05-17/app'; -import { AppComponent as S0601 } from '../06-01/app'; -import { AppComponent as S0603 } from '../06-03/app'; -import { AppComponent as S0701 } from '../07-01/app'; -import { AppComponent as S0703 } from '../07-03/app'; -import { AppComponent as S0704 } from '../07-04/app'; -import { AppComponent as S0901 } from '../09-01/app'; +import { ROUTER_DIRECTIVES } from '@angular/router'; @Component({ selector: 'my-app', templateUrl: 'app/app.component.html', directives: [ROUTER_DIRECTIVES] }) -@RouteConfig([ - { path: '/01-01', name: '01-01', component: S0101 }, - { path: '/02-07', name: '02-07', component: S0207 }, - { path: '/02-08', name: '02-08', component: S0208 }, - { path: '/03-01', name: '03-01', component: S0301 }, - { path: '/03-02', name: '03-02', component: S0302 }, - { path: '/03-03', name: '03-03', component: S0303 }, - { path: '/03-04', name: '03-04', component: S0304 }, - { path: '/03-05', name: '03-05', component: S0305 }, - { path: '/03-06', name: '03-06', component: S0306 }, - { path: '/04-10', name: '04-10', component: S0410 }, - { path: '/04-14', name: '04-14', component: S0414 }, - { path: '/05-02', name: '05-02', component: S0502 }, - { path: '/05-03', name: '05-03', component: S0503 }, - { path: '/05-04', name: '05-04', component: S0504 }, - { path: '/05-12', name: '05-12', component: S0512 }, - { path: '/05-13', name: '05-13', component: S0513 }, - { path: '/05-14', name: '05-14', component: S0514 }, - { path: '/05-15', name: '05-15', component: S0515 }, - { path: '/05-16', name: '05-16', component: S0516 }, - { path: '/05-17', name: '05-17', component: S0517 }, - { path: '/06-01', name: '06-01', component: S0601 }, - { path: '/06-03', name: '06-03', component: S0603 }, - { path: '/07-01', name: '07-01', component: S0701 }, - { path: '/07-03', name: '07-03', component: S0703 }, - { path: '/07-04', name: '07-04', component: S0704 }, - { path: '/09-01', name: '09-01', component: S0901 }, - -]) export class AppComponent { } diff --git a/public/docs/_examples/style-guide/ts/app/app.routes.ts b/public/docs/_examples/style-guide/ts/app/app.routes.ts new file mode 100644 index 0000000000..9254169331 --- /dev/null +++ b/public/docs/_examples/style-guide/ts/app/app.routes.ts @@ -0,0 +1,61 @@ +import { provideRouter, RouterConfig } from '@angular/router'; + +import { AppComponent as S0101 } from '../01-01/app'; +import { AppComponent as S0207 } from '../02-07/app'; +import { AppComponent as S0208 } from '../02-08/app'; +import { AppComponent as S0301 } from '../03-01/app'; +import { AppComponent as S0302 } from '../03-02/app'; +import { AppComponent as S0303 } from '../03-03/app'; +import { AppComponent as S0304 } from '../03-04/app'; +import { AppComponent as S0305 } from '../03-05/app'; +import { AppComponent as S0306 } from '../03-06/app'; +import { AppComponent as S0410 } from '../04-10/app'; +import { AppComponent as S0414 } from '../04-14/app'; +import { AppComponent as S0502 } from '../05-02/app'; +import { AppComponent as S0503 } from '../05-03/app'; +import { AppComponent as S0504 } from '../05-04/app'; +import { AppComponent as S0512 } from '../05-12/app'; +import { AppComponent as S0513 } from '../05-13/app'; +import { AppComponent as S0514 } from '../05-14/app'; +import { AppComponent as S0515 } from '../05-15/app'; +import { AppComponent as S0516 } from '../05-16/app'; +import { AppComponent as S0517 } from '../05-17/app'; +import { AppComponent as S0601 } from '../06-01/app'; +import { AppComponent as S0603 } from '../06-03/app'; +import { AppComponent as S0701 } from '../07-01/app'; +import { AppComponent as S0703 } from '../07-03/app'; +import { AppComponent as S0704 } from '../07-04/app'; +import { AppComponent as S0901 } from '../09-01/app'; + +const routes: RouterConfig = [ + { path: '01-01', component: S0101 }, + { path: '02-07', component: S0207 }, + { path: '02-08', component: S0208 }, + { path: '03-01', component: S0301 }, + { path: '03-02', component: S0302 }, + { path: '03-03', component: S0303 }, + { path: '03-04', component: S0304 }, + { path: '03-05', component: S0305 }, + { path: '03-06', component: S0306 }, + { path: '04-10', component: S0410 }, + { path: '04-14', component: S0414 }, + { path: '05-02', component: S0502 }, + { path: '05-03', component: S0503 }, + { path: '05-04', component: S0504 }, + { path: '05-12', component: S0512 }, + { path: '05-13', component: S0513 }, + { path: '05-14', component: S0514 }, + { path: '05-15', component: S0515 }, + { path: '05-16', component: S0516 }, + { path: '05-17', component: S0517 }, + { path: '06-01', component: S0601 }, + { path: '06-03', component: S0603 }, + { path: '07-01', component: S0701 }, + { path: '07-03', component: S0703 }, + { path: '07-04', component: S0704 }, + { path: '09-01', component: S0901 }, +]; + +export const APP_ROUTER_PROVIDERS = [ + provideRouter(routes) +]; diff --git a/public/docs/_examples/style-guide/ts/app/main.ts b/public/docs/_examples/style-guide/ts/app/main.ts index 5eec1d8f88..b58fbb68dd 100644 --- a/public/docs/_examples/style-guide/ts/app/main.ts +++ b/public/docs/_examples/style-guide/ts/app/main.ts @@ -1,15 +1,15 @@ import { bootstrap } from '@angular/platform-browser-dynamic'; -import { ROUTER_PROVIDERS } from '@angular/router-deprecated'; import { XHRBackend, HTTP_PROVIDERS } from '@angular/http'; import { HashLocationStrategy, LocationStrategy } from '@angular/common'; import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api'; import 'rxjs/add/operator/map'; +import { APP_ROUTER_PROVIDERS } from './app.routes'; import { HeroData } from './hero-data'; import { AppComponent } from './app.component'; bootstrap(AppComponent, [ - ROUTER_PROVIDERS, + APP_ROUTER_PROVIDERS, HTTP_PROVIDERS, { provide: LocationStrategy, useClass: HashLocationStrategy }, { provide: XHRBackend, useClass: InMemoryBackendService },