in Angular by
Demonstrate navigating between different routes in an Angular application.

▼ Show 1 Answer

0 votes
Following code demonstrates how to navigate between different routes in an Angular app dubbed “Some Search App”:

import {Router} from "@angular/router";





  selector: 'app-header',

  template: `

<nav class="navbar navbar-light bg-faded">

  <a class="navbar-brand" (click)="goHome()">Some Search App</a>

  <ul class="nav navbar-nav">

    <li class="nav-item">

      <a class="nav-link" (click)="goHome()">Home</a>


    <li class="nav-item">

      <a class="nav-link" (click)="goSearch()">Search</a>






class HeaderComponent {

  constructor(private router: Router) {}

  goHome() {



  goSearch() {



Angular JS
Learn More with Madanswer

Related questions

+1 vote
asked Jan 15, 2020 in Angular by rahuljain1