I have followed the instructions in the documentation regarding persisting the filter state. (http://plnkr.co/edit/ekwiNt?p=preview)
When re-loading the page, the table state (including filters) is restored, however the <select>
box appears blank, even though the filter does work.
The text filter works fine.
Angular 1.4.7 Smart-table 2.1.5
Here is the plunker https://embed.plnkr.co/fK6WfZSZrgSeIG732R2X/
.directive('stPersist', function() {
return {
require: '^stTable',
link: function(scope, element, attr, ctrl) {
var nameSpace = attr.stPersist;
//save the table state every time it changes
scope.$watch(function() {
return ctrl.tableState();
}, function(newValue, oldValue) {
if (newValue !== oldValue) {
localStorage.setItem(nameSpace, JSON.stringify(newValue));
}
}, true);
//fetch the table state when the directive is loaded
if (localStorage.getItem(nameSpace)) {
var savedState = JSON.parse(localStorage.getItem(nameSpace));
var tableState = ctrl.tableState();
angular.extend(tableState, savedState);
ctrl.pipe();
}
}
};
});;