@ViewChild |
@ViewChildren
|
@ContentChild
|
@ContentChildren
|
dom 操作(ViewChild)
<div #myattr></div>
import { Component ,ViewChild,ElementRef} from '@angular/core';
@ViewChild('myattr') myattr: ElementRef;
ngAfterViewInit(){
let attrEl = this.myattr.nativeElement;
}
ViewChild 调用子组件 的方法
<app-footer #footerChild></app-footer>
import { Component, OnInit ,ViewChild} from '@angular/core’;
@ViewChild('footerChild') footer;
run(){
this.footer.footerRun();
}