Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module('app', ['ngAnimate']);
- app.controller('itemsController', function( $scope ) {
- $scope.divisions = [{id:12, div_name:' city1'},
- {id:13, div_name:' city2'},
- {id:14, div_name:' city3'}];
- $scope.works =[{wid:111, w_name:'work1'},
- {wid:222, w_name:'work2'},
- {wid:333, w_name:'work3'}];
- $scope.sub_works =[{wid:111, swid:001, swork:'swork1'},
- {wid:222, swid:002, swork:'swork2'},
- {wid:333, swid:003, swork:'swork3'},
- {wid:111, swid:004, swork:'swork4'}];
- $scope.save = function(data){
- alert(JSON.stringify(data));
- }
- });
- <table border="1">
- <tbody ng-repeat-start="division in divisions">
- <td>
- {{division.div_name}}
- <em>{{expanded}}</em>
- </td>
- <td>Values: {{divisions.length}}</td>
- <td>
- <button type="button" ng-click="expanded = !expanded">
- Expand
- </button>
- </td>
- </tbody>
- <tbody ng-repeat-end ng-show="expanded" ng-init='data={id:division.id,div_name:division.div_name,works:[]}'>
- <td colspan="3">
- <select ng-model="data.tt">
- <option value='01'>tt1..........</option>
- <option value='02'>tt2..........</option>
- </select><br/><br/>
- <ul ng-repeat="work in works" ng-init='data.works[$index]={wid:work.wid,w_name:work.w_name,sworks:[]}'>
- <strong>{{$index+1}}. {{work.w_name}} </strong>
- <li ng-repeat="sub in sub_works | filter : { wid : work.wid }"
- ng-init="data.works[$index].sub_works[$index]={swid:sub.swid,swork:sub.swork}">
- {{sub.swork}}
- <input type=text ng-model='data.works[$index].sub_works[$index].input' />
- </li>
- </ul><br/><br/>
- {{data | json}}
- <button ng-click="save(data)">save</button>
- </td>
- </tbody>
- </table>{{result |json}}
Add Comment
Please, Sign In to add comment