Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 单击“更新”后,我想导航到“更新”中的员工,我缺少什么?_Angular_Angular7 Router - Fatal编程技术网

Angular 单击“更新”后,我想导航到“更新”中的员工,我缺少什么?

Angular 单击“更新”后,我想导航到“更新”中的员工,我缺少什么?,angular,angular7-router,Angular,Angular7 Router,我在app-routing.module.ts中添加了路由 我已在路由文件中配置路径employees/:id 在employee.ts中,我编写了一个导航到updateemployees组件的函数,但它没有发生 const routes: Routes = [ { path: '',component:EmployeesComponent}, { path: 'employees',component:EmployeesComponent}, { path: 'employees/

我在app-routing.module.ts中添加了路由 我已在路由文件中配置路径employees/:id 在employee.ts中,我编写了一个导航到updateemployees组件的函数,但它没有发生

const routes: Routes = [
  { path: '',component:EmployeesComponent},
  { path: 'employees',component:EmployeesComponent},
  { path: 'employees/:id',component:UpdateEmployeeComponent}
];
我在employee.component.ts中编写了一个函数

updateEmployee(id){
    console.log(`Update Employee ${id}`);
    this.router.navigate(['employees/', id]);
  }
但我无法导航到更新员工组件。我缺少什么?

试试这个:

 updateEmployee(id){
    console.log(`Update Employee ${id}`);
    this.router.navigate(['employees', id]);
  }
检查是否在html文件中添加了
。和使用

this.router.navigate(['employee',id])
相对路径或

this.router.navigateByUrl('/employee/'+id)
绝对路径