Note that there are some explanatory texts on larger screens.

plurals
  1. POangularjs toggle on selectall and deselect
    text
    copied!<p>I am using the following AngularJS code...</p> <pre><code>&lt;div ng-controller="MyCtrl"&gt; &lt;h4&gt;I have {{friends.length}} friends. They are...&lt;/h4&gt; &lt;span id="selectall" ng-click="selectAllFriends()"&gt;&lt;u&gt;Select All&lt;/u&gt;&lt;/span&gt; &lt;br&gt; &lt;ul class="example-animate-container"&gt; &lt;li class="animate-repeat" ng-repeat="friend in friends"&gt; &lt;input type="checkbox" value="{{friend.id}}" ng-checked="friend.checked" ng-model="friend.checked" &gt; {{friend.id}} {{friend.name}} who is {{friend.age}} years old. &lt;/li&gt; &lt;/ul&gt; &lt;pre&gt;&lt;strong&gt;{{selectedFriends().length}} selected with filter:&lt;/strong&gt; {{friends | filter:{checked:true} | json}}&lt;/pre&gt; &lt;script&gt; function MyCtrl($scope, $filter) { // fruits $scope.friends = [ {id: 1, name:'John', age:25, gender:'boy'}, {id: 2, name:'Jessie', age:30, gender:'girl'}, {id: 3, name:'Johanna', age:28, gender:'girl'}, {id: 4, name:'Joy', age:15, gender:'girl'}, {id: 5, name:'Mary', age:28, gender:'girl'}, {id: 6, name:'Peter', age:95, gender:'boy'}, {id: 7, name:'Sebastian', age:50, gender:'boy'}, {id: 8, name:'Erika', age:27, gender:'girl'}, {id: 9, name:'Patrick', age:40, gender:'boy'}, {id: 10, name:'Samantha', age:60, gender:'girl'} ]; $scope.selectAllFriends = function() { angular.forEach($scope.friends, function(friend){ friend.checked = true; }); }; $scope.selectedFriends = function () { return $filter('filter')($scope.friends, {checked: true}); }; } &lt;/script&gt; </code></pre> <p>here is <a href="http://jsfiddle.net/fe4yZ/" rel="nofollow">jsfiddle</a></p> <p>Select All function is working fine, but i want to add is: after clicking Select All, text of it should be changed to Deselect All and all checkbox should be deselected, i think it could be possible using toggle, please help me with this, thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload