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 });
}
}