我是AngularJs的新手,正在尝试将Smart-Table插件“包装”在指令中。我可以得到行,但是分页没有显示
目前,这就是我所做的。
app.directive('grid', [ function () {
return {
restrict: 'E',
replace: true,
template: function (element, attrs) {
return '<table class="table table-striped">'
+ '<thead>'
+ ' <tr>'
+ '<th st-ratio="20" st-sort="Team">Team</th>'
+ '<th st-ratio="20" st-sort="TeamFreq">Team Freq</th>'
+ '<th st-ratio="10" st-sort="TeamSac">Team Sac</th>'
+ '<th st-ratio="30" st-sort="Priority">Priority</th>'
+ '</tr>'
+ '</thead>'
+ '<tbody>'
+ '<tr ng-repeat="row in dataset">'
+ ' <td>{{row.firstName}}</td>'
+ '<td>{{row.lastName | uppercase}}</td>'
+ '<td>{{row.age}}</td>'
+ '<td>{{row.email}}</td>'
+ '</tr>'
+ '</tbody>'
+ '<tfoot>'
+ '<tr>'
+ '<td colspan="4" class="text-center">'
+ '<div class="pagination pagination-xs m-top-none pull-right" st-pagination="1" st-items-by-page="itemsByPage" st-displayed-pages="4"></div>'
+ '</td>'
+ '</tr>'
+ '</tfoot>'
+ '</table>';
},
scope: {
},
controller: function ($scope) {
},
link: function (scope, elem, attrs) {
var nameList = ['Pierre', 'Pol', 'Jacques', 'Robert', 'Elisa'], familyName = ['Dupont', 'Germain', 'Delcourt', 'bjip', 'Menez'];
function createRandomItem() {
var
firstName = nameList[Math.floor(Math.random() * 4)],
lastName = familyName[Math.floor(Math.random() * 4)],
age = Math.floor(Math.random() * 100),
email = firstName + lastName + '@@whatever.com',
balance = Math.random() * 3000;
return {
firstName: firstName,
lastName: lastName,
age: age,
email: email,
balance: balance
};
}
scope.rowCollection = [];
for (var j = 0; j < 10; j++) {
scope.rowCollection.push(createRandomItem());
}
scope.dataset = [].concat(scope.rowCollection);
}
};
}]);我的html包含这个标签
<grid st-table="dataset"></grid>这段代码只是一个测试,数据将使用服务传递。并且模板将是动态的。我需要一些帮助:-)
谢谢
发布于 2014-10-29 16:50:31
前几天在指令中使用智能表时,我无法显示分页。事实证明,这与指令没有任何关系,我只是从GitHub下载/更新到最新版本的智能表,一切正常。我开始寻找已经改变了的东西,但被转移到了更有效率的东西上,很高兴它现在起作用了。我的版本似乎工作正常,被标记为1.4.2。
但是,对于来自服务的动态数据,我认为您还需要查看st-safe-src属性。虽然我对整个Angular / smart-table业务也是个新手。
发布于 2015-02-01 13:58:26
我相信您必须匹配st-table值和st-pagination值才能显示分页。
https://stackoverflow.com/questions/26531425
复制相似问题