mon*_*guy 2 angular2-template ngonchanges angular
我有下一个html:
<select [(ngModel)]="district" class="form-control" (change)="dsChange()">
<option disabled hidden [value]="undefined" >?????</option>
<option *ngFor="let dis of districts" [ngValue]="dis">{{dis.title}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我还有下一个组件
@Input() district: District;
ngOnChanges(changes: SimpleChanges) {
console.log("CHANGED")
}
dsChange(){
console.log(this.district);
}
Run Code Online (Sandbox Code Playgroud)
而且我不明白为什么当我选择一些值dsChange时会用区的正确值触发,但是ngOnChanges()却没有
| 归档时间: |
|
| 查看次数: |
3971 次 |
| 最近记录: |