有人可以解释这个例子
Plunker NG-Table
在HTML中,->
<tbody ng-repeat="group in $groups">
但是在js中没有为什么呢?
$组
最佳答案
当指定groupBy
ngTableParameter(ngTable module)时,you can see it in the github source code here 定义$ scope。$ groups。
$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()));
}
});
这是由ngTable在$ scope上创建的$ groups,用于plunker示例中的数据。
$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'}
]
}
]