Angular 2:如何将子组件绑定到属性

Angular 2: how to bind a subcomponent to property

如何将模板中的子组件主菜单绑定到 属性 菜单?

import { Component } from '@angular/core';

import { MainMenuComponent } from './main-menu.component';

@Component({
  selector: 'my-app',
  template: `
    <div class="centered">
      <mainmenu></mainmenu>
    </div>
  `
})
export class AppComponent {
  menu: MainMenuComponent;
}

带有 ViewChild 注释:

export class AppComponent {
  @ViewChild(MainMenuComponent) menu: MainMenuComponent;
}