Reputation: 1643
I have used ng2-modal for my modal.
When I call the following function I have created:
deleteCommitee(id:number){
var length = this.addnewCommitee.length;
for(var i = 0;i<length;i++){
if(id == i){
this.addnewCommitee.splice(i,i);
}
}
}
the modal disappears. I have replicated the situation in plunker.
In the plunker example please click the button to trigger the modal open and then click on cross button below 'email id 0' input field
Actually through this function I want to remove an element from addNewCommittee array
.
Upvotes: 1
Views: 94
Reputation: 29614
You are missing event.stopPropagation()
to prevent the click from propagating through the DOM.
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)" >
Upvotes: 3