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

feat(chips): md-max-chips support for md-contact-chips #12050

Merged
merged 1 commit into from
Dec 9, 2020
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
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