samedi 30 juillet 2016

Uncheck all checkboxes in AngularJS

I am having trouble finding a solution that allows me to simply uncheck all checkboxes using AngularJS. I use a simple ng-repeat to make checkboxes and want a button to clear them all.

        <div class="form-group">  <!-- Checkbox Group !-->
                    <label class="control-label">What are your requirements</label>
                    <div class="checkbox" ng-repeat="block in blocks">
                      <label>
                        <input type="checkbox" ng-model='myModel' name="block" value="block" ng-change="filter(block)">
                        
                      </label>
                    </div>
                </div>  

                <div> 
                    <input type="button" class="btn btn-primary " name="Clear" ng-click="reset()" value="Reset"> </input>
                </div>

I have tried altering the ng-model a few times, but keep getting errors since I use the ng-change function. Is there any way I can make a function called reset() in the controller to clear all the checkboxes (even if it is in a for loop iterating through each one by name)?

For referense

$scope.blocks = ["Lambda","Tokenization","Hadoop"];




Aucun commentaire:

Enregistrer un commentaire