javascript - Explanation of an example of NG -Table -
javascript - Explanation of an example of NG -Table -
someone can explain example
plunker ng-table
in html, there -->
<tbody ng-repeat="group in $groups">
but in js there no why ?
$groups
the ngtable module defines $scope.$groups when groupby
ngtableparameter specified (you can see in github source code here ).
$scope.tableparams = new ngtableparams({ page: 1, // show first page count: 10 // count per page }, { groupby: 'role', // << ----- grouping parameter total: data.length, getdata: function($defer, params) { var ordereddata = params.sorting() ? $filter('orderby')(data, $scope.tableparams.orderby()) : data; $defer.resolve(ordereddata.slice((params.page() - 1) * params.count(), params.page() * params.count())); } });
this $groups created on $scope ngtable, info in plunker example.
$scope.$groups = [ { value: 'administrator', data: [ {name: "moroni", age: 50, role: 'administrator'}, {name: "tiancum", age: 43, role: 'administrator'}, {name: "jacob", age: 27, role: 'administrator'} ] }, { value: 'moderator', data: [ {name: "nephi", age: 29, role: 'moderator'}, {name: "nephi", age: 29, role: 'moderator'}, {name: "tiancum", age: 43, role: 'moderator'}, {name: "enos", age: 34, role: 'moderator'} ] }, { value: 'user', data: [ {name: "enos", age: 34, role: 'user'}, {name: "tiancum", age: 43, role: 'user'}, {name: "jacob", age: 27, role: 'user'}, {name: "enos", age: 34, role: 'user'}, {name: "jacob", age: 27, role: 'user'}, {name: "nephi", age: 29, role: 'user'}, {name: "tiancum", age: 43, role: 'user'}, {name: "jacob", age: 27, role: 'user'}, {name: "nephi", age: 29, role: 'user'}, {name: "enos", age: 34, role: 'user'} ] } ]
javascript angularjs
Comments
Post a Comment