Guest User

Untitled

a guest
Nov 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. var app = angular.module('app', ['ngAnimate']);
  2.  
  3. app.controller('itemsController', function( $scope ) {
  4.  
  5. $scope.divisions = [{id:12, div_name:' city1'},
  6. {id:13, div_name:' city2'},
  7. {id:14, div_name:' city3'}];
  8.  
  9. $scope.works =[{wid:111, w_name:'work1'},
  10. {wid:222, w_name:'work2'},
  11. {wid:333, w_name:'work3'}];
  12.  
  13. $scope.sub_works =[{wid:111, swid:001, swork:'swork1'},
  14. {wid:222, swid:002, swork:'swork2'},
  15. {wid:333, swid:003, swork:'swork3'},
  16. {wid:111, swid:004, swork:'swork4'}];
  17.  
  18. $scope.save = function(data){
  19. alert(JSON.stringify(data));
  20. }
  21. });
  22.  
  23. <table border="1">
  24. <tbody ng-repeat-start="division in divisions">
  25. <td>
  26. {{division.div_name}}
  27. <em>{{expanded}}</em>
  28. </td>
  29. <td>Values: {{divisions.length}}</td>
  30. <td>
  31. <button type="button" ng-click="expanded = !expanded">
  32. Expand
  33. </button>
  34. </td>
  35. </tbody>
  36. <tbody ng-repeat-end ng-show="expanded" ng-init='data={id:division.id,div_name:division.div_name,works:[]}'>
  37. <td colspan="3">
  38.  
  39. <select ng-model="data.tt">
  40. <option value='01'>tt1..........</option>
  41. <option value='02'>tt2..........</option>
  42. </select><br/><br/>
  43. <ul ng-repeat="work in works" ng-init='data.works[$index]={wid:work.wid,w_name:work.w_name,sworks:[]}'>
  44. <strong>{{$index+1}}.&nbsp;{{work.w_name}} </strong>
  45. <li ng-repeat="sub in sub_works | filter : { wid : work.wid }"
  46. ng-init="data.works[$index].sub_works[$index]={swid:sub.swid,swork:sub.swork}">
  47.  
  48. {{sub.swork}}
  49. <input type=text ng-model='data.works[$index].sub_works[$index].input' />
  50. </li>
  51. </ul><br/><br/>
  52. {{data | json}}
  53. <button ng-click="save(data)">save</button>
  54. </td>
  55. </tbody>
  56. </table>{{result |json}}
Add Comment
Please, Sign In to add comment