Adding routing to our app
To learn more about routing in Angular 2, and for better understanding of the coming steps, you can visit the following URL: https://angular.io/docs/ts/latest/tutorial/toh-pt5.html.
Our simple website has the following pages: Home, Features, Pricing, and About. So we have to create four new components (views). For the home page, create a file call in home.component.ts
in the app
folder. The home.component.t
s file should contain the following TypeScript code:
import { Component } from '@angular/core'; @Component({ selector: 'home', template: '<h3>Home</h3>' }) export class HomeComponent { }
Repeat the preceding steps for each page, and create the features
, component.ts
, pricing.component.ts
, and about.component.ts
files too.
Then create a new app/app.routes.ts
file, which should contain the following TypeScript code:
import { provideRouter, RouterConfig } from '@angular/router'; import { HomeComponent...