Question - Demonstrate navigating between different routes in an Angular application.
Answer -
The following code demonstrates how to navigate between different routes in an Angular app dubbed “Some Search App”:
import from"@angular/router";
.
.
.
@Component({
selector: 'app-header',
template: `
`
})
classHeaderComponent {
constructor(private router: Router) {}
goHome() {
this.router.navigate(['']);
}
goSearch() {
this.router.navigate(['search']);
}
}