Do aux routes work for the root component only?

后端 未结 2 1344
旧时难觅i
旧时难觅i 2021-01-13 00:41

I\'m having trouble setting up auxiliary routes in child components, for some reason only those auxiliary routes work that start at the root component.

Here\'s my ro

相关标签:
2条回答
  • 2021-01-13 01:17

    Try using http://localhost:3000/shell/(department/1//aux2:test3)

    URL has format (primaryroute//secondaryroute) parentheses tells it may have sibling routes and // is sibling route separator.

    Aux and primary outlets are considered sibling on same parent

    0 讨论(0)
  • 2021-01-13 01:26

    some working example click here

    important points

    <a [routerLink]="['/component-one',{ outlets: { 'sidebar': ['component-aux'] } }]">Component One</a>
    
    @Component({
      selector: 'component-one',
      template: `Component One
        <div style="color: green; margin-top: 1rem;">Sidebar Outlet:</div>
        <div style="border: 2px solid blue; padding: 1rem;">
          <router-outlet name="sidebar"></router-outlet>
        </div>
      `
    })
    
    0 讨论(0)
提交回复
热议问题