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

Support multiple="multiple" attribute. #407

Merged
merged 2 commits into from
Nov 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,12 @@

var searchInput = element.querySelectorAll('input.ui-select-search');

$select.multiple = (angular.isDefined(attrs.multiple)) ? (attrs.multiple === '') ? true : (attrs.multiple.toLowerCase() === 'true') : false;
$select.multiple = angular.isDefined(attrs.multiple) && (
attrs.multiple === '' ||
attrs.multiple.toLowerCase() === 'multiple' ||
attrs.multiple.toLowerCase() === 'true'
);

$select.closeOnSelect = (angular.isDefined(attrs.closeOnSelect) && attrs.closeOnSelect.toLowerCase() === 'false') ? false : uiSelectConfig.closeOnSelect;
$select.onSelectCallback = $parse(attrs.onSelect);
$select.onRemoveCallback = $parse(attrs.onRemove);
Expand Down
16 changes: 16 additions & 0 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,22 @@ describe('ui-select tests', function() {
.toBe("Wladimir <wladimir@email.com>Samantha <samantha@email.com>Nicole <nicole@email.com>");

});

it('should support multiple="multiple" attribute', function() {

var el = compileTemplate(
'<ui-select multiple="multiple" ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
<ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
<div ng-bind-html="person.name | highlight: $select.search"></div> \
<div ng-bind-html="person.email | highlight: $select.search"></div> \
</ui-select-choices> \
</ui-select> \
'
);

expect(el.scope().$select.multiple).toBe(true);
});
});

describe('default configuration via uiSelectConfig', function() {
Expand Down