【发布时间】:2016-09-18 13:53:23
【问题描述】:
我有 2 个<router-outlet>,一切正常,这是我在配置文件组件中的RouteConfig:
@Component({
selector : "profile",
templateUrl: '/client/tmpl/profile.html',
directives: [ ROUTER_DIRECTIVES],
})
@RouteConfig([
{name: 'Home', component: homeProfile ,path: '/' ,useAsDefault:true},
{name: 'Credit', component: credit ,path: '/credit' },
{name: 'BuyCredit', component: buyCredit ,path: '/buycredit' }
])
我的问题是当我想在 credit 组件中使用 [routerLink] 时会抛出错误:
“credit”没有路由配置。在[空]
这是我的credit 组件:
import {ROUTER_DIRECTIVES,RouteConfig} from 'angular2/router';
@Component({
selector : "credit",
templateUrl : "client/tmpl/profile/credit.html",
directives: [ROUTER_DIRECTIVES]
})
模板:
<ul>
<li><a [routerLink]="['Profile' , 'Home']" href="#">home</a> </li>
</ul>
为什么要在credit Component里面使用RouteConfig?以及如何使用?
【问题讨论】:
标签: javascript angularjs routes angular angular2-routing