Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 4503295

Browse files
BrianLenzouser378230
authored andcommitted
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
1 parent e59e008 commit 4503295

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/uiSelectDirective.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,15 @@ uis.directive('uiSelect',
7474
});
7575
}
7676

77-
scope.$watch('searchEnabled', function() {
78-
var searchEnabled = scope.$eval(attrs.searchEnabled);
79-
$select.searchEnabled = searchEnabled !== undefined ? searchEnabled : uiSelectConfig.searchEnabled;
77+
scope.$watch(function () { return scope.$eval(attrs.searchEnabled); }, function(newVal) {
78+
$select.searchEnabled = newVal !== undefined ? newVal : uiSelectConfig.searchEnabled;
8079
});
8180

8281
scope.$watch('sortable', function() {
8382
var sortable = scope.$eval(attrs.sortable);
8483
$select.sortable = sortable !== undefined ? sortable : uiSelectConfig.sortable;
8584
});
86-
85+
8786
attrs.$observe('limit', function() {
8887
//Limit the number of selections allowed
8988
$select.limit = (angular.isDefined(attrs.limit)) ? parseInt(attrs.limit, 10) : undefined;

0 commit comments

Comments
 (0)