【发布时间】:2016-06-03 12:40:14
【问题描述】:
这是我的父组件:
@Component({
selector : "app",
template : '
<app-header></app-header>
<top-navigation></top-navigation>
<router-outlet></router-outlet>
<app-footer></app-footer>
<page-js-rersources></page-js-rersources>',
directives : [AppHeader, AppFooter]
})
@RouteConfig([
{path: '/', name: "UserHome", component: LandingPage, useAsDefault: true },
{path: '/login', name: "Login", component: LoginSignUp },
{path: '/splash', name: "SplashBuildup", component: Splash },
{path: '/home', name: "HomeBuildup", component: Home }
])
export class UserLayoutBuildUp{
constructor(){
}
}
这是我的子组件:
@Component({
templateUrl: "splash.tmpl.htm",
})
export class Splash{
}
这是我的顶级导航组件:
@Component({
selector: "top-navigation",
templateUrl: "topNavigation.tmpl.htm"
})
export class TopNavigation{
}
我想在 UserLayoutBuildUp 组件的 top-navigation 选择器中包含我的顶部导航组件。
我已经尝试过 Angular 2 文档,但无法弄清楚有关将组件注入顶级选择器的任何信息。
【问题讨论】:
-
您是否尝试过使用可以在
UserLayoutBuildUp和Splash中注入的服务? -
不,我没有。 UserLayoutBuildUp 是我的引导组件,我希望我的 topNavigation 组件在任何路径都处于活动状态时处于活动状态
-
你能提供一些构建相同的东西吗
-
我确实为你提供了一些东西:)
标签: angular angular2-routing angular2-directives