javascript - How can I clear all checkboxes from ng-repeat? -


i have method value objects selected, , ".length" indicate @ user how many objects selected. have cancel button , clear checkboxes , reset ".length"

$scope.selection = []; $scope.toggleselection = function toggleselection(image) {       var idx = $scope.selection.indexof(image);     // selected     if (idx > -1) {         $scope.selection.splice(idx, 1);     }     // newly selected     else {         $scope.selection.push(image);     }      $scope.totalitems = $scope.selection.length;      $scope.itemobject = {         'attachments': $scope.selection     }; 

this ng-repeat:

<ul ng-repeat="image in images | filter:query attachmensresults">                         <li>                             <div class="cbxdelete">                                 <input class="checkbx" id="ckbox" type="checkbox" value="{{image.id}}" ng-checked="selection.indexof(image.id) > -1" ng-click="toggleselection(image.id)" />                             </div>                             <a href="{{image._links.file.href}}" data-lightbox="example-set" data-title="click right half of image move forward.">                                 <div class="img-preview">                                     <img ng-src="{{image._links.file.href}}" alt="" />                                 </div>                             </a>                         </li>                     </ul> 

why not this?

<button ng-click="cancel()">cancel</button>  $scope.cancel = function(){    $scope.selection = [];    $scope.totalitems = 0;     $scope.itemobject = { 'attachments': $scope.selection }; } 

this reset selection array empty, ng-checked false.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -