<ul class="show-result">
<li *ngFor="let staff of allStaffs;">
<div>
<input type="checkbox" >{{ staff.perscode }} | {{ staff.personName }}
</div>
</li>
</ul>
<button class="btn btn-primary ripple" (click)="addSelectedStaff()">Add</button>
where all staff value is
allStaffs = [{
"perscode":23277,
"personName":"Rahma Said Ali",
"personCategoryCode":1011,
"personCategoryName":"A.Pharmacist"
},
{
"perscode":24825,
"personName":"Zainab Abdul Baqi",
"personCategoryCode":1011,
"personCategoryName":"A.Pharmacist"
} ]
How can I get the selected check boxes at Add button click
I have tried to Add this code in angular2 component. I need to know which all are checked. This is not working.
addSelectedStaff(){
console.log("@@ selected options :"+this.selectedOptions);
}
get selectedOptions() { // right now: ['1','3']
return this.allStaffs
.filter(opt => opt.perscode)
.map(opt => opt.personName)
}
Need to get the entire selected object list.