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

Commit

Permalink
fix(searchEnabled): watch evaluated attribute value
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
BrianLenzo authored and user378230 committed Jul 7, 2016
1 parent e59e008 commit 4503295
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4503295

Please sign in to comment.