如何将模板中的子组件主菜单绑定到属性菜单?
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;
}