Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 455c679

Browse files
lievenjanssenmmalerba
authored andcommitted
fix(md-contact-chips): support md-min-length on md-contact-chips. (#9215)
* fix(md-contact-chips): support md-min-length on md-contact-chips. Add md-min-length to md-contact-chips and propagate attribute to md-autocomplete. Add md-has-not-found=true attribute to md-autocomplete. Fixes #2423. * fix(md-contact-chips): remove md-has-not-found from md-autocomplete. * fix(md-contact-chips): added test for md-min-length on md-contact-chips. * fix(md-contact-chips): rename test for md-min-length on md-contact-chips.
1 parent 1e45c44 commit 455c679

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/components/chips/contact-chips.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('<md-contact-chips>', function() {
88
md-contact-image="image"\
99
md-contact-email="email"\
1010
md-highlight-flags="i"\
11+
md-min-length="1"\
1112
placeholder="To">\
1213
</md-contact-chips>';
1314

@@ -85,6 +86,15 @@ describe('<md-contact-chips>', function() {
8586
expect(chip.find('img').length).toBe(0);
8687
});
8788

89+
it('should forward md-min-length attribute to the autocomplete', inject(function() {
90+
var element = buildChips(CONTACT_CHIPS_TEMPLATE);
91+
92+
var autocompleteElement = element.find('md-autocomplete');
93+
var autocompleteCtrl = autocompleteElement.controller('mdAutocomplete');
94+
95+
expect(autocompleteCtrl.scope.minLength).toBe(parseInt(element.attr('md-min-length')));
96+
}));
97+
8898
describe('filtering selected items', function() {
8999
it('should filter', inject(function() {
90100
scope.querySearch = jasmine.createSpy('querySearch').and.callFake(function(q) {

src/components/chips/js/contactChipsDirective.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ angular
2929
* contact's email address.
3030
* @param {string} md-contact-image The field name of the contact object representing the
3131
* contact's image.
32+
* @param {number=} md-min-length Specifies the minimum length of text before autocomplete will
33+
* make suggestions
3234
*
3335
*
3436
* @param {expression=} filter-selected Whether to filter selected contacts from the list of
@@ -63,6 +65,7 @@ var MD_CONTACT_CHIPS_TEMPLATE = '\
6365
md-items="item in $mdContactChipsCtrl.queryContact($mdContactChipsCtrl.searchText)"\
6466
md-item-text="$mdContactChipsCtrl.itemName(item)"\
6567
md-no-cache="true"\
68+
md-min-length="$mdContactChipsCtrl.minLength"\
6669
md-autoselect\
6770
placeholder="{{$mdContactChipsCtrl.contacts.length == 0 ?\
6871
$mdContactChipsCtrl.placeholder : $mdContactChipsCtrl.secondaryPlaceholder}}">\
@@ -118,6 +121,7 @@ function MdContactChips($mdTheming, $mdUtil) {
118121
contactEmail: '@mdContactEmail',
119122
contacts: '=ngModel',
120123
requireMatch: '=?mdRequireMatch',
124+
minLength: '=?mdMinLength',
121125
highlightFlags: '@?mdHighlightFlags'
122126
}
123127
};

0 commit comments

Comments
 (0)