Javascript 复选框被选中,即使我在其外部单击
我已经实现了复选框组,所以当我们单击特定复选框时,参数应该被选中,但即使我在所有复选框分组区域的复选框外单击,它也会被选中。帮帮我,我做错了什么?仅当我们单击复选框时,才必须选择该参数Javascript 复选框被选中,即使我在其外部单击,javascript,angular,typescript,checkbox,Javascript,Angular,Typescript,Checkbox,我已经实现了复选框组,所以当我们单击特定复选框时,参数应该被选中,但即使我在所有复选框分组区域的复选框外单击,它也会被选中。帮帮我,我做错了什么?仅当我们单击复选框时,才必须选择该参数 changeValue(事件:任意,项目:任意){ 如果(事件){ this.activeParameter.paramList[项目].selected=true; this.selectedItems.push(this.activeParameter.paramList[item].value) }否则{
changeValue(事件:任意,项目:任意){
如果(事件){
this.activeParameter.paramList[项目].selected=true;
this.selectedItems.push(this.activeParameter.paramList[item].value)
}否则{
this.activeParameter.paramList[项目].selected=false;
让我们选择;
selected=this.selectedItems.filter((数据:any)=>data!==this.activeParameter.paramList[item].value)
this.selectedItems=已选择;
}
this.activeParamCount=this.selectedItems.length;
this.groupSelected=未定义;
}
{{paramtegorie.lable}
{{activeParameter.paramList[param]?activeParameter.paramList[param]。标签:“NA”}
您可以尝试这样做#
}你可以试着这样做#
}发布更多代码。发布更多代码。更新代码。请立即检查是否可以创建演示并发布URL?请仅尝试[ngModel]并在函数changeEvent中写入
activeParameter.paramList[param].selected=event
第一次发布更多代码。发布更多代码。更新了代码。请立即检查是否可以创建演示并发布URL?请仅尝试[ngModel]并在函数changeEvent中写入activeParameter.paramList[param]。selected=event
第一次
changeValue(event: any, item: any) {
this.activeParameter.paramList[item].selected = !this.activeParameter.paramList[item].selected;
if (this.activeParameter.paramList[item].selected === true) {
this.selectedItems.push(this.activeParameter.paramList[item].value)
} else {
this.activeParameter.paramList[item].selected = false;
let selected;
selected = this.selectedItems.filter( (data: any) => data !== this.activeParameter.paramList[item].value)
this.selectedItems = selected;
}
this.activeParamCount = this.selectedItems.length;
this.groupSelected = undefined;