将数据传递到子路由组件

时间:2016-11-20 19:57:15

标签: javascript angularjs angular

我想知道是否可以将输入数据传递给我们作为子路径加载的组件,例如,假设我有这个组件

import { Component, OnInit, Input } from '@angular/core';

@Component({
    moduleId: module.id,
    selector: 'selector',
    templateUrl: 'feature.component.html'
})
export class FeatureComponent implements OnInit {

    constructor() { }
    @Input()
    data: string = "";

    ngOnInit() { }
}

在我的应用程序中,我使用此组件如下:     

但现在我想将此组件作为子路由加载,如下所示:

{ path: 'user/:userid', component: HomeComponent, canActivate: [AuthGuard],
    children: [
        { path: 'overview', component: FeatureComponent }
    ]
 }

替换选择器
 <router-outlet></router-outlet>

是否可以将输入字符串作为输入传递给子路径?

非常感谢!!

0 个答案:

没有答案
相关问题