javascript - AngularJs generate categories from array -


<table class="table-striped table-bordered table-condensed">     <tbody>         <tr ng-if="$index%3==0" ng-repeat="permission in vm.parent.getallpermissions()">             <td ng-repeat="i in [0,1,2]" class="col-xs-2">                 <span>                 <input type="checkbox" checklist-model="vm.data.permissions" checklist-value="vm.parent.getpermission($parent.$index+i)">                  {{vm.parent.getpermissiontitle($parent.$index+i) || " "}}                 </span>             </td>         </tr>     </tbody> </table> 

that's angularjs now. json this. there n users, , categories , and permissions

{   "admin": {     "category": "admin",     "permission": "admin"   },   "user": {     "category": "user",     "permission": "user"   } } 

vm.getallpermissions() returns data. want split users , permissions, want have categories split ui-tab , under each tab permissions displayed table.

i have tried this

var permissionarray =[]; object.keys(vmgetallpermissions).map(function(category, key) {  for(var key in vmgetallpermissions) {     if(vmgetallpermissions.hasownproperty(key)) {         permissionarray.push(category,key);      } }  }); 

it doesn't work gives idea of i'm trying do. view looks this

enter image description here

category admin, tab @ top, list of permissions checkboxes are. i'm pretty sure have provide category parameter vm.parent.getallpermissions i'm not @ angular nor js, prefer ask you.

i think need need push 1 value @ time -- push object. code this: (just add curly braces)

permissionarray.push({category,key}); 

here's example: https://jsfiddle.net/yh0ugp6q/1/


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -