角路由链接未更新页面(URL也未更改)

时间:2019-09-24 14:47:37

标签: angular

我有一个8号角站点。我有一个组件,希望从数据库中切换某些项目后更新UI。本质上,我有活动项目和非活动项目。我在页面上放置了一个按钮来调用API,并将活动状态从true更改为false,反之亦然,然后返回角度组件,我想在不刷新整个页面的情况下更新UI。我正在使用页面刷新功能,以使其对用户无缝。目前,页面可以正确更新,这很棒,但是我不能使用菜单栏将routerLink链接到任何其他页面。任何帮助将不胜感激。

toggleStatus(id, status) {
    let changeStatus = {
      active: status
    }
    this._projectService.toggleStatus(id, changeStatus).subscribe(
      response => {
        console.log(response['message']);
      this.reloadComponent();
      },
    error => console.log(error['message'])
    )
  }


///// FUNCTION TO RELOAD PAGE AFTER DELETE /////
  reloadComponent() {
    this._router.routeReuseStrategy.shouldReuseRoute = () => false;
    this._router.onSameUrlNavigation = 'reload';
    this._router.navigate(['admin/projects']);
  }

1 个答案:

答案 0 :(得分:0)

尝试将this._router.navigate(['admin/projects']);更改为

 this._router.navigate(['./admin/projects']);