Angularjs 无法匹配路由索引

Angularjs 无法匹配路由索引,angularjs,angular,Angularjs,Angular,使用angular 2路由器(3.0.0-rc.1)和angular 2(RC5)的最新版本。我的路由器有以下路由: { path: 'transport', redirectTo: 'transport/entity-list', pathMatch: 'full'}, { path: 'transport/entity-list', component: EntityListComponent }, { path: 'transport/cover-list', component: Cov

使用angular 2路由器(3.0.0-rc.1)和angular 2(RC5)的最新版本。我的路由器有以下路由:

{ path: 'transport', redirectTo: 'transport/entity-list', pathMatch: 'full'},
{ path: 'transport/entity-list', component: EntityListComponent },
{ path: 'transport/cover-list', component: CoverListComponent },
{ path: 'transport/invoice-list', component: InvoiceListComponent },
{ path: 'transport/damage-list', component: DamageListComponent }
我的服务器(ExpressJS)具有pug库,并按如下方式呈现我的索引:

res.render('index');
我的index.pug中也有base标记

head
    base(href="/")
MyComponent
中,我还导入了
ROUTER\u指令

加载索引时,所有内容都会呈现,但出现以下错误:

Error: Uncaught (in promise): Error: Cannot match any routes: 'index'
据我所知,angular的路由器正在尝试路由索引,但在路径中看不到它。因此,我尝试将
索引添加为路径,但得到:

Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'MyComponent'
我有两个问题:

  • 我做错了什么?我怎样才能摆脱这个错误
  • 如何从一开始就获取索引加载
    传输/实体列表

  • 您必须将
    pathMatch:'full'
    添加到您的中,而不是
    useAsDefault

    { path: 'transport', redirectTo: 'transport/entity-list', pathMatch: 'full'},
    

    路由上缺少索引路径,因此您所做的是正确的

    关于你的其他问题:

    Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'MyComponent'
    
    您的模板上是否定义了此项

    <router-outlet></router-outlet>
    
    
    
    谢谢,但是没有用……我更改了问题中的
    路径匹配!似乎路由器试图路由
    /index
    !这很奇怪,因为/index有
    基(href=“/”
    ),即使我添加
    /index
    路径,它也不会“找到”它实际上是的,但在我的app.component.js中,它是通过systemJS加载的(如angular 2文档中建议的),我意识到我在延迟路由器出口的创建以加载我的应用程序数据!谢谢你指出这一点