My HTML:
<div class="panel-body">
<span ng-repeat="industry in ctrl.industryList">
<label>
<input type="checkbox" id="industry" ng-model="ctrl.oneIndustry" ng-change="ctrl.updateSelected(industry)">
</label><br/>
</span>
</div>
I am iterating through an array of industries and displaying a checkbox. When the checkbox is ticked, it is stored into an array. If the checkbox is then unticked, I would like to remove it from the array:
My Controller code:
vm.updateSelected = function (industry) {
if (vm.oneIndustry) {
vm.industries.push(industry)
}
else{
vm.industries.pop(industry)
}}
The current problem is when a checkbox is clicked, All of the items in the list get ticked although only the once which is clicked is saved. On untick, the item is removed from the list and all checkboxes become unticked. How do I tick and untick only the specific tickbox?
Aucun commentaire:
Enregistrer un commentaire