Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head ng-app="myApp">
- <link rel="stylesheet" href="style.css">
- <script data-require="angular.js@1.2.7" data-semver="1.2.7" src="http://code.angularjs.org/1.2.7/angular.js"></script>
- <script src="script.js"></script>
- </head>
- <body ng-controller="ToddlerCtrl">
- <table>
- <tr ng-repeat="item in child.Cars1">
- <td>
- <input ng-model="table.selected" type="checkbox" name="a{{$index}}" id="a{{$index}}">{{ item.name }}
- </td>
- <td>
- <div>
- <input type="radio" ng-model="item.operation" value="0" name="b{{$index }}" id="b{{$index}}">Clear
- </div>
- <div>
- <input type="radio" ng-model="item.operation" value="1" name="b{{$index }}" id="b{{$index}}">Clear and Save
- </div>
- </td>
- </tr>
- </table>
- </body>
- </html>
- // Instantiate the app, the 'myApp' parameter must
- // match what is in ng-app
- var myApp = angular.module('myApp', []);
- // Create the controller, the 'ToddlerCtrl' parameter
- // must match an ng-controller directive
- myApp.controller('ToddlerCtrl', function ($scope) {
- // Define an array of Toddler objects
- $scope.parent.cars1 = ["Saab", "BMW"];
- $scope.child = {};
- if ($scope.child.Cars1 === undefined)
- $scope.child.Cars1 = [];
- angular.forEach($scope.parent.Cars1, function (obj, key) {
- $scope.child.Cars1.push(
- {
- name: obj,
- operation: 1, // this value is used to tick all radio button of clear and save
- selected: true // this value is used to check all checkbox to true by default
- }
- );
- });
- console.log($scope.child.Cars1);
- });
Add Comment
Please, Sign In to add comment