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

Commit

Permalink
feat(limit): Change multi-select limit attr (#1632)
Browse files Browse the repository at this point in the history
attr.limit should be an observable property so that it is
updatable after initialization
  • Loading branch information
cauld authored and aaronroberson committed May 31, 2016
1 parent faaca57 commit f5888fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ uis.directive('uiSelect',
$select.onSelectCallback = $parse(attrs.onSelect);
$select.onRemoveCallback = $parse(attrs.onRemove);

//Limit the number of selections allowed
$select.limit = (angular.isDefined(attrs.limit)) ? parseInt(attrs.limit, 10) : undefined;

//Set reference to ngModel from uiSelectCtrl
$select.ngModel = ngModel;

Expand All @@ -86,6 +83,11 @@ uis.directive('uiSelect',
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;
});

scope.$watch('removeSelected', function() {
var removeSelected = scope.$eval(attrs.removeSelected);
Expand Down

0 comments on commit f5888fb

Please sign in to comment.