Link to home
Start Free TrialLog in
Avatar of eugene007
eugene007

asked on

Multiple Checkbox value to controller

In each bootstrap collapse expand panel I have a table with two columns and multiple rows created. Each row has a checkbox.

Now when I press Update Permission button, I intend to send two values to my angularjs controller namely perm.id and value.id for each row to process.

<div class="col-xs-12">

	<div class="row">
		<div class="col-md-12 margin-tb">
			<div class="pull-left">
				<h1>Listing Module</h1>
			</div>
			<div class="pull-right">
				<input type="button" ng-click="updPermission()" value="Update Permission">  
			</div>
		</div>
	</div>
		
	<div ng-repeat="value in module">
         <div class="panel-group">
              <div class="panel panel-default">
                  <div class="panel-heading">
                    <h4 class="panel-title">
						 <a class="accordion-toggle" data-toggle="collapse" data-target="#collapseModule{{value.id}}">
                            <i class="glyphicon glyphicon-collapse-down"></i>{{value.name}}
						 </a>
                    </h4>
                  </div>
                  <div id="collapseModule{{value.id}}" class="panel-collapse in">
					<div class="panel-body">
						
						<table class="moduleGrid table-striped table-bordered table-hover table-condensed">
						   <thead>
							  <tr>
								 <th>Permission</th>
								 <th>Status</th>
							  </tr>
						   </thead>
						   <tbody>
							  <!-- Now just ng-repeat the rows -->
							  <tr ng-repeat="perm in value.permission">
								 <td>
									{{perm.name}}
								</td>
								 <td>
									<input name="permStatus" type="checkbox"  ng-model="ngModel" ng-checked={{perm.status}}  ng-true-value="{{perm.id}}"/>
								 </td>
							  </tr>
						   </tbody>
						</table>
								
                    </div>
                  </div>
              </div>
        </div>
    </div>
	
	<br/><br/><br/><br/><br/>

</div>

Open in new window


How can I go about with this. Your help is kindly appreciated.

Thank You.
Avatar of eugene007
eugene007

ASKER

I did some changes to the checkbox

<input 
	name="{{perm.name}}" 
	type="checkbox"  
	ng-model="perm.status" 
	ng-checked="{{perm.status}}" 
	ng-true-value="{{perm.id}}" 
	ng-click="checkItems(value.id,perm.id)"
/>

Open in new window


and in my angularjs controller I did this

	$scope.groups = [];
	
	$scope.checkItems = function(module,permission){
		 $scope.groups.push({mod:module,perm:permission});
	}

Open in new window


Now I am trying to identify whether a checkbox is checked or unchecked.
I replaced the following line of code

	ng-click="checkItems(value.id,perm.id)"

Open in new window


to

	ng-change="checkItems(value.id,perm.id)"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of eugene007
eugene007

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial