I am new to Angular.
I wanted to navigate different component based on the drop down value using Angular 6.
I have used router Module and am getting the values from drop down, but how to navigate to component based on the value of the drop down.
find the code
1> app.routing.module
const routes: Routes = [
{path:'about',component : AboutComponent},
{path:'home',component : HomeComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
2> app.component.ts
export class AppComponent {
navLinks = [
{ path : 'home', label : 'Home', id: 1 },
{ path : 'about', label : 'About', id: 2 }
];
3> app.component.html
<nav>
<select id="department" name="department" [(ngModel)]="department" class="form-control">
<option *ngFor="let links of navLinks" [value]="links.id" [routerLink]="links.path" routerLinkActive #rla="routerLinkActive">
{{links.label}}
</option>
</select>
</nav>