Search code examples
angular-ui-routerangular2-routingangular2-services

How to route using list in Dropdown Angular 2


 <select class="form-control" id="category" required [(ngModel)]="model.category" name="category" #category="ngModel">
<option disabled>None</option>
<option> Add New </option>                                
<option *ngFor= "let i of data1"  [value]="i.id">{{i.category}}</option>                                    
 </select>

If i select Add New Option from dropdown it should Route to this path ['/pages/products/dashboard'] .

I already Tried by passed that link in <option [routerLink]="['/EmployeeData']"> but it doesn't work.


Solution

  • You can listen to the onchange event on the select element and have your routing logic in a function that triggers when the event comes from the Add New option.

    Example