Angular 2: NavigationCancel - Navigation ID 2 is not equal to the current navigation id 3

后端 未结 4 1999
北荒
北荒 2020-12-16 10:50

I\'m trying to redirect old URLs (links in email templates) from a previous site to another route like this:

if (route.url.indexOf(\'/#/\') !== -1) {
    thi         


        
4条回答
  •  眼角桃花
    2020-12-16 11:46

    If you are generating routerLink through an array of routes from .ts file. And your routes contain resolvers...

    
        This
       
    {{route}}
    and This
    {{route}}
    and this too
    {{route}}

    then don't try this...with resolver...It won't work...

    The safer way is simply create a function in ts file.

    navigate(link: string): void
      {
        this.router.navigate([link]);
      }
    

    and call this function from html...like this

    
       
    {{route}}

    It will work fine....Happy Coding!!!

提交回复
热议问题