Guest User

Untitled

a guest
Mar 2nd, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head ng-app="myApp">
  5. <link rel="stylesheet" href="style.css">
  6. <script data-require="angular.js@1.2.7" data-semver="1.2.7" src="http://code.angularjs.org/1.2.7/angular.js"></script>
  7. <script src="script.js"></script>
  8. </head>
  9.  
  10. <body ng-controller="ToddlerCtrl">
  11. <table>
  12. <tr ng-repeat="item in child.Cars1">
  13. <td>
  14. <input ng-model="table.selected" type="checkbox" name="a{{$index}}" id="a{{$index}}">{{ item.name }}
  15. </td>
  16. <td>
  17. <div>
  18. <input type="radio" ng-model="item.operation" value="0" name="b{{$index }}" id="b{{$index}}">Clear
  19. </div>
  20. <div>
  21. <input type="radio" ng-model="item.operation" value="1" name="b{{$index }}" id="b{{$index}}">Clear and Save
  22. </div>
  23. </td>
  24. </tr>
  25. </table>
  26. </body>
  27.  
  28. </html>
  29.  
  30.  
  31.  
  32. // Instantiate the app, the 'myApp' parameter must
  33. // match what is in ng-app
  34. var myApp = angular.module('myApp', []);
  35.  
  36. // Create the controller, the 'ToddlerCtrl' parameter
  37. // must match an ng-controller directive
  38. myApp.controller('ToddlerCtrl', function ($scope) {
  39.  
  40. // Define an array of Toddler objects
  41. $scope.parent.cars1 = ["Saab", "BMW"];
  42. $scope.child = {};
  43.  
  44. if ($scope.child.Cars1 === undefined)
  45. $scope.child.Cars1 = [];
  46.  
  47. angular.forEach($scope.parent.Cars1, function (obj, key) {
  48. $scope.child.Cars1.push(
  49. {
  50. name: obj,
  51. operation: 1, // this value is used to tick all radio button of clear and save
  52. selected: true // this value is used to check all checkbox to true by default
  53. }
  54. );
  55. });
  56.  
  57. console.log($scope.child.Cars1);
  58.  
  59. });
Add Comment
Please, Sign In to add comment