/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {APP_BASE_HREF} from '@angular/common'; import {Component, NgModule, OnInit, ɵNgModuleFactory as NgModuleFactory} from '@angular/core'; import {BrowserModule, platformBrowser} from '@angular/platform-browser'; import {ActivatedRoute, Router, RouterModule, Routes} from '@angular/router'; @Component({ selector: 'app-list', template: `
`, }) class ListComponent { } @Component({ selector: 'app-item', template: ` Item {{id}} `, }) class ItemComponent implements OnInit { id = -1; constructor(private activatedRoute: ActivatedRoute, private router: Router) {} ngOnInit() { this.activatedRoute.paramMap.subscribe(paramsMap => { this.id = +paramsMap.get('id')!; }); } viewList() { this.router.navigate(['/list']); } } @Component({ selector: 'app-root', template: `