Angular 2 辅助路由器坏了吗? [英] Is Angular 2 Auxiliary router broken?

查看:27
本文介绍了Angular 2 辅助路由器坏了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为聊天窗口创建一个带有辅助路由的应用.该应用程序在加载时失败.这似乎是一个错误,我在 Angular GitHub 上报告了它,但我想知道是否有人知道解决方法?这是这个简单应用程序的主要内容:http://plnkr.co/edit/JsZbuR

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.

推荐答案

你要等到 issue https://github.com/angular/angular/issues/4694 将得到解决.

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

当前实现只允许

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

查看链接 http://plnkr.co/edit/lquMdagaVfIoAT83w1pl?p=preview

这篇关于Angular 2 辅助路由器坏了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆