问题
Where is the filtered collection after filtered value in smart table.
the table is bound with rowCollection
.
<table st-safe-src="rowCollection" st-table="displayed" class="table table-bordered">
and i have used a search filter:
<input type="text" id="regionFilter" st-search="region" />
after the result are filtered i still see all records in rowCollection
回答1:
You can create a directive to access the get the filtered Collection. For example:
HTML:
<table
st-table="displayedCollection"
st-safe-src="rowCollection"
on-filter="onFilter">
Javascript:
//
// Create a directive
//
angular.module("smart-table").directive('onFilter', function () {
return {
require: '^stTable',
scope: {
onFilter: '='
},
link: function (scope, element, attr, ctrl) {
scope.$watch(function () {
return ctrl.tableState().search;
}, function (newValue, oldValue) {
scope.onFilter(ctrl);
}, true);
}
};
});
//
// In your controller
//
$scope.onFilter = function (stCtrl) {
var filtered = stCtrl.getFilteredCollection();
}
来源:https://stackoverflow.com/questions/29194548/angular-js-smart-table-filtered-collection