Javascript 操纵角组件中的复选框
我试图在选中另一个复选框时更改复选框选中状态。在我看来,它工作正常,但我可以在chrome inspect工具中看到Javascript 操纵角组件中的复选框,javascript,angular,angular5,Javascript,Angular,Angular5,我试图在选中另一个复选框时更改复选框选中状态。在我看来,它工作正常,但我可以在chrome inspect工具中看到ng reflect model=“true”在不应该的时候。这是我的代码示例 component.html 当点击store时,我希望customer被取消选中(行为如此实际),customer checked状态为false(仍然为true)。我如何才能实现这个结果?我想我需要以这种方式对ngModel进行更改 isCustomerChange() { this.isCus
ng reflect model=“true”
在不应该的时候。这是我的代码示例
component.html
当点击store时,我希望customer被取消选中(行为如此实际),customer checked状态为false(仍然为true)。我如何才能实现这个结果?我想我需要以这种方式对
ngModel
进行更改
isCustomerChange() {
this.isCustomer = !this.isCustomer;
this.user['isCustomer'] = this.isCustomer;
this.user.isStore = false;
}
isStoreChange() {
this.isStore = !this.isStore;
this.user['isStore'] = this.isStore;
this.user.isCustomer = false;
}
export class RegisterComponent implements OnInit {
isStore: boolean = false;
isCustomer: boolean = false;
isCustomerChange() {
this.isCustomer = !this.isCustomer;
this.user['isCustomer'] = this.isCustomer;
this.isStore = false;
}
isStoreChange() {
this.isStore = !this.isStore;
this.user['isStore'] = this.isStore;
this.isCustomer = false;
}
}
isCustomerChange() {
this.isCustomer = !this.isCustomer;
this.user['isCustomer'] = this.isCustomer;
this.user.isStore = false;
}
isStoreChange() {
this.isStore = !this.isStore;
this.user['isStore'] = this.isStore;
this.user.isCustomer = false;
}