I have the following routes defined in my application ...
app.components.ts @RouteConfig([ {path:'/employees/...', name:'Employees', component:EmployeeComponent}, ... employee.component.ts @RouteConfig([ {path:'/', name:'EmployeeList', component:EmployeeListComponent, useAsDefault: true}, {path:'/:id', name:'EmployeeDetail', component:EmployeeDetailComponent} ])
When I head from EmployeeDetailComponent ...
<button class="btn btn-default" [routerLink]="['EmployeeList']">Close</button>
attach routes to the employee list page, as expected.
However, when I route using router.navigate ...
// template <button class="btn btn-default" (click)="save()">Save</button> // EmployeeDetailComponent saveEmployee() { this._employeeServer.updateEmployee(this.employee); this._router.navigate(['EmployeeList']); }
the application sends a list of employees (as expected), and then, after a few moments, the application restarts completely (not as expected).
Any idea why router.navigate behaves differently than routerLink? What am I missing?
angular angular2-routing
Todd breyman
source share