mardi 7 juillet 2015

how to handle multiple checkbox in angularjs

i have a list of checkbox which is created dynamically based on the groups and items. below is the code im using to generate the list. how to use ng-modal to save the values back to db and during editing , how to select the checkbox if it is selected already ? sorry if im not clear in anyway

<!DOCTYPE html>
<html>
<head>
<script src="http://ift.tt/1bdM3QL"></script>
<title>Groups</title>
</head>
<body>
<div ng-app="app" ng-controller="myCtrl">
  <table>
    <thead>
        <tr>
            <th> Groups </th>
            <th ng-repeat = "grp in group.Groups" > {{grp.Group}} </th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat = "item in items.items">
            <td>{{item.item}}</td>
            <td ng-repeat = "grp in group.Groups">
            <input type="checkbox" >
            </td>
        </tr>
    </tbody>
  </table>
</div>

</body>
</html>

<script>
    var app = angular.module('app', []);

app.controller('myCtrl', function($scope) 
{

  $scope.group = {"Groups":[{"id":0,"Group":"Group A"},{"id":0,"Group":"Group B"},{"id":0,"Group":"Group C"},{"id":0,"Group":"Group D"}]};

  $scope.items = {"items":[{"id":0,"item":"item1"},{"id":0,"item":"item2"},{"id":0,"item":"item3"},{"id":0,"item":"item4"},{"id":0,"item":"item5"}]};


});
</script>




Aucun commentaire:

Enregistrer un commentaire