使用get,set关键字
get返回父组件变化后的值
set为组件值产生变化后父组件改变
import {Input, Output } from '@angular/core';
........
this.myModelValue : boolean;
@Input()
get myModel(){
return this.myModelValue;
}
set myModel(val:boolean){
this.myModelValue = val;
this.myModelChange.emit(this.myModelValue);
}
@Output() myModelChange:EventEmitter<string> = new EventEmitter<string>();
output绑定事件,由组件绑定事件E