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

Commit

Permalink
feat(chips): md-max-chips support for md-contact-chips
Browse files Browse the repository at this point in the history
Closes #10827
  • Loading branch information
kylekatarnls authored and Splaktar committed Dec 9, 2020
1 parent 71dc4eb commit e6b5482
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/chips/js/chipsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,9 @@ MdChipsCtrl.prototype.resetChipBuffer = function() {
* @returns {boolean} true if the max chips limit has been reached, false otherwise.
*/
MdChipsCtrl.prototype.hasMaxChipsReached = function() {
if (angular.isString(this.maxChips)) this.maxChips = parseInt(this.maxChips, 10) || 0;
if (angular.isString(this.maxChips)) {
this.maxChips = parseInt(this.maxChips, 10) || 0;
}

return this.maxChips > 0 && this.items.length >= this.maxChips;
};
Expand Down
5 changes: 5 additions & 0 deletions src/components/chips/js/contactChipsDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ angular
* contact's email address.
* @param {string} md-contact-image The field name of the contact object representing the
* contact's image.
* @param {number=} md-max-chips The maximum number of chips allowed to add through user input.
* <br/><br/>The validation property `md-max-chips` can be used when the max chips
* amount is reached.
* @param {number=} md-min-length Specifies the minimum length of text before autocomplete will
* make suggestions
* @param {string=} md-input-class This class will be applied to the child `md-autocomplete` for
Expand Down Expand Up @@ -83,6 +86,7 @@ var MD_CONTACT_CHIPS_TEMPLATE = '\
ng-model="$mdContactChipsCtrl.contacts"\
ng-change="$mdContactChipsCtrl.ngChange($mdContactChipsCtrl.contacts)"\
md-require-match="$mdContactChipsCtrl.requireMatch"\
md-max-chips="{{$mdContactChipsCtrl.maxChips}}"\
md-chip-append-delay="{{$mdContactChipsCtrl.chipAppendDelay}}"\
md-separator-keys="$mdContactChipsCtrl.separatorKeys"\
md-autocomplete-snap>\
Expand Down Expand Up @@ -154,6 +158,7 @@ function MdContactChips($mdTheming, $mdUtil) {
ngChange: '&?',
requireMatch: '=?mdRequireMatch',
minLength: '=?mdMinLength',
maxChips: '=?mdMaxChips',
highlightFlags: '@?mdHighlightFlags',
chipAppendDelay: '@?mdChipAppendDelay',
separatorKeys: '=?mdSeparatorKeys',
Expand Down

0 comments on commit e6b5482

Please sign in to comment.