我在我的模式中使用了ng2-modal。
当我调用我创建的以下函数时:
deleteCommitee(id:number){
var length = this.addnewCommitee.length;
for(var i = 0;i<length;i++){
if(id == i){
this.addnewCommitee.splice(i,i);
}
}
}模态消失了。我已经在plunker中复制了这种情况。
在柱塞示例中,请单击按钮以触发模式打开,然后单击'email id 0‘输入字段下面的叉号按钮
实际上,通过这个函数,我想从addNewCommittee array中删除一个元素。
发布于 2017-03-10 19:41:54
您缺少阻止单击通过DOM传播的event.stopPropagation()。Updated plunker
deleteCommitee
deleteCommitee(id:number,event:any){
//event.preventDefault();
event.stopPropagation();
for(var i = 0;i<this.addnewCommitee.length;i++){
console.log(this.addnewCommitee[i]);
if(id == this.addnewCommitee[i].count){
//console.log(this.addnewCommitee[i]);
console.log(this.addnewCommitee.splice(i,1));
}
}
}HTML
<div class="close_icon_div cursor_pointer" (click)="deleteCommitee(newCommitee.count,$event)" >https://stackoverflow.com/questions/42717036
复制相似问题