2
我有複選框,我想用(change)
就可以了。默認爲「已選中」,但點擊後我想清除輸入文字「激活密鑰」。重新檢查後,我想生成GUID並再次輸入。如何選中複選框或不選?處理更改複選框Angular2
<div class="checkbox">
<label>
<input type="checkbox" checked (change)="handleChange($event)" >
Generate key
</label>
</div>
TS
handleChange(e) {
var isChecked = e.isChecked;
if (isChecked) {
this.gatewayForm.patchValue({ 'activationKey': this.guid() });
}
else {
this.gatewayForm.controls['activationKey']
.setValue('', { onlySelf: true });
}
}