Testing route parameters 

You will have some component that does routing and some components that are being routed to. Sometimes components that are being routed to have a parameter, and typically their route looks something like this: /jedis/:id. The component then has the mission of digging out the ID parameter and doing a lookup on the specific Jedi that matches this ID. So, a call to a service will be made and the response should populate  a suitable parameter in our component that we then can show in the template. Such a component will typically look like this, in its entirety:

import { ActivatedRoute, Router } from '@angular/router';import { Component, OnInit } from '@angular/core';import { Observable } from 'rxjs/Rx';import { Jedi ...

Get Learning Angular - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.