网格视图 html
<input id="successFilter" name='filterInput' [(ngModel)]="filterInput" type="text" (keyup)="searchSuccess($event)">
GridView 打字稿
import { Output, OnInit } from '@angular/core';
@Component({
selector: 'app-gridView',
templateUrl: './gridView.component.html',
styleUrls: ['./gridView.component.scss']
})
export class GridViewComponent implements OnInit {
@Output() sendValue = new EventEmitter<string>();
filterInput = '';
constructor(){}
ngOnInit() {}
getValue() {
this.sendValue.emit(this.filterInput);
}
}
ParentComponent 打字稿,在需要获取值时调用 getChildValue()
@ViewChild('gridView') grdView;
getChildValue() {
this.grdView.getValue();
}
receivedValue(theValue: string) {
//this is where you actually get theValue
}
父组件 html
<app-gridView #gridView (sendValue)="receivedValue($event)"></app-gridView>