Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- path: '',
- component: HomeComponent
- },
- {
- path: ':name',
- component: HomeComponent
- }
- <h1 class="title">
- {{name ? name : "Noone"}}'s Home
- </h1>
- <button routerLink="{{n}}" *ngFor="let n of names">{{n}}</button>
- import { Component, OnInit } from '@angular/core';
- import { ActivatedRoute } from '@angular/router';
- @Component({
- selector: 'app-home',
- templateUrl: './home.component.html',
- styleUrls: ['./home.component.scss']
- })
- export class HomeComponent implements OnInit {
- constructor(private readonly _activatedRoute: ActivatedRoute) {
- if (this._activatedRoute.snapshot.paramMap.has("name"))
- this.name = this._activatedRoute.snapshot.paramMap.get("name");
- }
- public name: string;
- public names = ["jack", "giorgia", "andrew", "alexia", "francesca", "luke"];
- ngOnInit() {
- }
- }
Add Comment
Please, Sign In to add comment