Within my Angular application, I have a series of checkboxes generated using a nested ng-repeat
:
<div ng-repeat="partner in type.partners">
<label class="checkbox-inline">
<input type="checkbox"
ng-model="partners[$parent.$index][$index]"
ng-true-value="{{partner}}"
ng-change="handleCheckboxChanged({{type.id}})"
ng-checked="getChecked({{partner.id}})"
>
<p><span ></span>{{partner.name}}<p>
</label>
</div>
The resulting layout is illustrated below:
https://i.sstatic.net/CovX4.png
Upon selecting a partner through a checkbox, it joins the list of selected partners utilizing ng-true-value
and ng-model
.
If a user decides to unselect a partner by unticking the checkbox, the object still retains the key:value pair with a value of false
, as shown in the console here:
https://i.sstatic.net/3Ajf5.png
I would prefer for this key:value pair to be removed entirely upon unchecking a checkbox, rather than simply changing its value to false.
Is there a way to achieve this by utilizing a function as the ng-false-value
trigger?