From 6d6b04e1cddaac8938d98a691203f8288367541d Mon Sep 17 00:00:00 2001 From: Marco de Jong Date: Wed, 8 Jul 2015 16:17:30 +0200 Subject: [PATCH 1/2] When not set via predicate update options as well. --- src/stSelectFilter.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/stSelectFilter.js b/src/stSelectFilter.js index 97b5d946..b92d5d25 100644 --- a/src/stSelectFilter.js +++ b/src/stSelectFilter.js @@ -41,10 +41,20 @@ ng.module('smart-table') // options as array of objects, eg: [{label:'green', value:true}, {label:'red', value:false}] scope.options = scope.attrOptions.slice(0); // copy values + + // when the table data is updated, also update the options + scope.$on('st-safeSrcChanged', function() { + scope.options = scope.attrOptions.slice(0); // copy values + }); } else { // options as simple array, eg: ['apple', 'banana', 'cherry', 'strawberry', 'mango', 'pineapple']; scope.options = getOptionObjectsFromArray(scope.attrOptions); + + // when the table data is updated, also update the options + scope.$on('st-safeSrcChanged', function() { + scope.options = getOptionObjectsFromArray(scope.attrOptions); + }); } } else { if (angular.isUndefined(scope.predicate) || scope.predicate === '') { From 735b1aea02776c33c603f3418f29ec34c68276ca Mon Sep 17 00:00:00 2001 From: Marco de Jong Date: Tue, 21 Jul 2015 11:14:59 +0200 Subject: [PATCH 2/2] Watch Options attribute change instead of tabledata change --- src/stSelectFilter.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stSelectFilter.js b/src/stSelectFilter.js index b92d5d25..d1896835 100644 --- a/src/stSelectFilter.js +++ b/src/stSelectFilter.js @@ -42,17 +42,17 @@ ng.module('smart-table') // options as array of objects, eg: [{label:'green', value:true}, {label:'red', value:false}] scope.options = scope.attrOptions.slice(0); // copy values - // when the table data is updated, also update the options - scope.$on('st-safeSrcChanged', function() { - scope.options = scope.attrOptions.slice(0); // copy values + // keep watching if the options change outside of the table + scope.$watch("attrOptions", function() { + scope.options = scope.attrOptions.slice(0); }); } else { // options as simple array, eg: ['apple', 'banana', 'cherry', 'strawberry', 'mango', 'pineapple']; scope.options = getOptionObjectsFromArray(scope.attrOptions); - // when the table data is updated, also update the options - scope.$on('st-safeSrcChanged', function() { + // keep watching if the options change outside of the table + scope.$watch("attrOptions", function() { scope.options = getOptionObjectsFromArray(scope.attrOptions); }); }