Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck-all checkbox is not changes object properties from select
    primarykey
    data
    text
    <p><a href="http://plnkr.co/edit/P5hBFam0aDswIts9a0jr?p=preview" rel="nofollow noreferrer">My Code - Plunker</a></p> <p>I'm trying to changes status of all my <code>list</code> <code>objects</code> by using a master <code>checkbox</code> that checks all <code>objects</code> and changes their properties by selecting the required status from the <code>select element</code>.</p> <p>The problem is that when I'm trying to apply change on all <code>elements</code> by using the "Check All" 'checkbox' it is not working.</p> <p><strong>e.g.</strong></p> <p><img src="https://i.stack.imgur.com/uA5Tx.png" alt="Example"></p> <p>When I check manually all the <code>checkboxes</code> without using the master <code>checkbox</code> it is working.</p> <p><strong>My Code</strong></p> <pre><code>var webApp = angular.module('webApp', []); //controllers webApp.controller ('VotesCtrl', function ($scope, Votes) { $scope.votes = Votes; $scope.statuses = ["Approved","Pending","Trash","Spam"]; $scope.expand = function(vote) { console.log("show"); $scope.vote = vote; $scope.ip = vote.ip; $scope.date = vote.created; }; $scope.change = function() { for(var i = 0; i &lt; $scope.votes.length; i++) { if($scope.votes[i].cb) { $scope.votes[i].status = $scope.votes.status; $scope.votes[i].cb = false; } $scope.show = false; } }; }); //services webApp.factory('Votes', [function() { //temporary repository till integration with DB this will be translated into restful get query var votes = [ { id: '1', created: 1381583344653, updated: '222212', ratingID: '3', rate: 5, ip: '198.168.0.0', status: 'Pending', }, { id: '111', created: 1381583344653, updated: '222212', ratingID: '4', rate: 5, ip: '198.168.0.1', status: 'Spam' }, { id: '2', created: 1382387322693, updated: '222212', ratingID: '3', rate: 1, ip: '198.168.0.2', status: 'Approved' }, { id: '4', created: 1382387322693, updated: '222212', ratingID: '3', rate: 1, ip: '198.168.0.3', status: 'Spam' } ]; return votes; }]); </code></pre> <p><strong>My HTML</strong></p> <pre><code> &lt;body ng-controller='VotesCtrl'&gt; &lt;div&gt; &lt;ul&gt; &lt;li class="check" ng-click=&gt; &lt;input type="checkbox" ng-model="master"&gt;&lt;/input&gt; &lt;/li&gt; &lt;li class="created"&gt; &lt;a&gt;CREATED&lt;/a&gt; &lt;/li&gt; &lt;li class="ip"&gt; &lt;b&gt;IP ADDRESS&lt;/b&gt; &lt;/li&gt; &lt;li class="status"&gt; &lt;b&gt;STATUS&lt;/b&gt; &lt;/li&gt; &lt;/ul&gt; &lt;ul ng-repeat="vote in votes"&gt; &lt;li class="check"&gt; &lt;input type="checkbox" ng-model="vote.cb" ng-checked="master"&gt;&lt;/input&gt; &lt;/li&gt; &lt;li class="created"&gt; &lt;a href="#" ng-click="expand(vote)"&gt;{{vote.created|date}}&lt;/a&gt; &lt;/li&gt; &lt;li class="ip"&gt; {{vote.ip}} &lt;/li&gt; &lt;li class="status"&gt; {{vote.status}} &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;br&gt;&lt;/br&gt; &lt;div class="details"&gt; &lt;h3&gt;Details:&lt;/h3&gt; &lt;div&gt;DATE: {{date|date}}&lt;/div&gt; &lt;div&gt;IP: {{ip}}&lt;/div&gt; &lt;div&gt;STATUS: &lt;select ng-change="change()" ng-init="votes.status='Approved'" ng-model="votes.status" ng-options="status for status in statuses"&gt; &lt;/select&gt; &lt;p&gt;{{vote.status|json}}&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>Why is master <code>checkbox</code> not working?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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