Ilya Schukin
Ilya Schukin

Reputation: 303

checkbox ng-false-value as null

I have a an angularjs checkboxes with the following markup:

<div class="ml20" ng-repeat="rate in auraInfo.rates">
    <label class="aura-checkbox">
         <input type="checkbox" 
                ng-model="model.checkedRates[$index]" 
                ng-true-value="{{ rate.id }}" 
                ng-false-value="????" />
    </label>
</div>

checkedRates is an array that gets filled with identifiers when the user is checking the checkboxes. There's also a button that sends these identifiers to the server. If the user check and uncheck the same checkbox a "false" value is sent to server.

How can I set a null value (or fully remove the item from the array) when the checkbox is unchecked?

Thanks in advance :)

Upvotes: 4

Views: 4594

Answers (1)

Dustin Kingen
Dustin Kingen

Reputation: 21245

Does ng-false-value="{{ null }}" not work? If not then you'll probably need to filter the null values from the array in the form submit.

Upvotes: 3

Related Questions