While trying to implement Checkbox functionality,I am not able to obtain which checkboxes the user has selected. How is this done? Below is my HTML snippet:
<td>
<table border="0"><th>Tier</th>
<tr ng-repeat="item in tiertype">
<td>
<label class="checkbox" for="{{item.id}}">
<input type="checkbox" ng-model="selection.ids[item.id]" name="tier_class" ng-checked="item.checked" id="{{item.id}}"/>{{item.name}}
</label>
</td></tr></table>
</td>
And below is my javascript snippet:
$scope.tiertype = [
{ id: 1, name: "All", checked: true},
{ id: 2, name: "Standard", checked: false },
{ id: 3, name: "Unreserved", checked: false },
{ id: 3, name: "Reserved", checked: false },
{ id: 4, name: "General", checked: false }
];
Iam not getting proper values on using "check box value= {{selection.ids}}". Moreover, on checking any checbox, all are getting checked or the checbox with id:1 (default). Seems strange to me, not able to figure out. Where am I going wrong as I dont have much experience in AngularJS.
ng-model="item.checked"
– CodeHater Sep 3 at 14:58