我创建了自己的指令进行分页之前可以访问数据表:
angular.module('smart-table')
.directive('stFilteredCollection', function() {
return {
restrict: 'A',
require: '^stTable',
scope: {
stFilteredCollection: '='
},
controller: 'stTableController',
link: function (scope, element, attr, ctrl) {
scope.$watch(function() {
return ctrl.getFilteredCollection();
}, function (newValue, oldValue) {
scope.stFilteredCollection = ctrl.getFilteredCollection();
});
}
};
});
要使用它,请添加st-filtered-collection
属性与变量,它从表分页前设置的数据名称:
<table st-table="..." st-safe-src="..." st-filtered-collection="filteredCollection">
...
</table>
从现在控制器中可以使用$scope.filteredCollection
变量。