Is Angular 2 Auxiliary router broken?

…衆ロ難τιáo~ 提交于 2019-12-11 02:02:06

问题


I'm trying to create an app with an auxiliary route for a chat window. The app fails right on the loading. It seems like a bug and I reported it on Angular GitHub, but I wonder if anyone knows a workaround? Here's the plunk of this simple app: http://plnkr.co/edit/JsZbuR

@Component({
  selector: 'basic-routing',
  template: `
    <a [router-link]="['/Home']">Home</a>
    <a [router-link]="['/ProductDetail']">Product Details</a>
    <router-outlet></router-outlet>
    <router-outlet name="chat"></router-outlet>
    <a [router-link]="['/', ['Chat']]">Chat</a>
  `,
  directives: [ ROUTER_DIRECTIVES ]
})
@RouteConfig([
  {path: '/',        component: HomeComponent,          as: 'Home'},
  {path: '/product', component: ProductDetailComponent, as: 'ProductDetail'         },
  {aux:  '/chat',    component: ChatComponent,          as: 'Chat'}
])
class RootComponent { /* ... */ }

It's not clear how the router knows which named route outlet to use.


回答1:


You have to wait until the issue https://github.com/angular/angular/issues/4694 will be solved.

Current implementation allows only

this.router.navigateByUrl('/(chat)');

See the link http://plnkr.co/edit/lquMdagaVfIoAT83w1pl?p=preview



来源:https://stackoverflow.com/questions/33442363/is-angular-2-auxiliary-router-broken

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!