From 45032957de11791d1be761d8279ef31189fd8f84 Mon Sep 17 00:00:00 2001 From: Brian Lenzo Date: Thu, 7 Jul 2016 12:01:04 -0400 Subject: [PATCH] fix(searchEnabled): watch evaluated attribute value `searchEnabled` was not reacting to changes in it's value. This was because searchEnabled has a scope.$watch on it but searchEnabled was set as a property on $select not the scope and the watch would never fire. This commit now changes the watch so it the attrs.searchEnabled for changes and properly reacts to changes in it's value. Closes #505 --- src/uiSelectDirective.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/uiSelectDirective.js b/src/uiSelectDirective.js index c6b5de4ea..7ecca4258 100644 --- a/src/uiSelectDirective.js +++ b/src/uiSelectDirective.js @@ -74,16 +74,15 @@ uis.directive('uiSelect', }); } - scope.$watch('searchEnabled', function() { - var searchEnabled = scope.$eval(attrs.searchEnabled); - $select.searchEnabled = searchEnabled !== undefined ? searchEnabled : uiSelectConfig.searchEnabled; + scope.$watch(function () { return scope.$eval(attrs.searchEnabled); }, function(newVal) { + $select.searchEnabled = newVal !== undefined ? newVal : uiSelectConfig.searchEnabled; }); scope.$watch('sortable', function() { var sortable = scope.$eval(attrs.sortable); $select.sortable = sortable !== undefined ? sortable : uiSelectConfig.sortable; }); - + attrs.$observe('limit', function() { //Limit the number of selections allowed $select.limit = (angular.isDefined(attrs.limit)) ? parseInt(attrs.limit, 10) : undefined;