Angular2 RouterLink breaks routes by replacing slash with /

后端 未结 5 1097
失恋的感觉
失恋的感觉 2020-12-03 22:11

Since the latest Angular2 version (2.0.0-beta.14) it is possible to have query parameters that contain multiple slashes, like /foo/bar.

This works great, however whe

5条回答
  •  余生分开走
    2020-12-03 22:50

    If you use Angular 7 or higher, and the other answers don't work out for you, you might have some problems with your paths.

    It works if you define a path with multiple slashes. However, when working with translations, I got an error.

    [{
      path: 'parentX',
      children: [
       {
         path: 'y/z'
         component: AnyComponent
       }
      ]
    }]
    

    All credit goes to Dabbas' question and answer

    It took me a while to land on his solution, which is why I added it here.

    [{
      path: 'parentX',
      children: [
       {
         path: 'y',
         children: [
           {
            path: 'z',
            component: AnyComponent
           }
         ]
       }
      ]
    }]
    

提交回复
热议问题