diff --git a/src/components/chips/js/chipsController.js b/src/components/chips/js/chipsController.js index fe5a1046489..f4b0288ff34 100644 --- a/src/components/chips/js/chipsController.js +++ b/src/components/chips/js/chipsController.js @@ -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; }; diff --git a/src/components/chips/js/contactChipsDirective.js b/src/components/chips/js/contactChipsDirective.js index c4d56ef90e2..d89c095159f 100644 --- a/src/components/chips/js/contactChipsDirective.js +++ b/src/components/chips/js/contactChipsDirective.js @@ -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. + *

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 @@ -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>\ @@ -154,6 +158,7 @@ function MdContactChips($mdTheming, $mdUtil) { ngChange: '&?', requireMatch: '=?mdRequireMatch', minLength: '=?mdMinLength', + maxChips: '=?mdMaxChips', highlightFlags: '@?mdHighlightFlags', chipAppendDelay: '@?mdChipAppendDelay', separatorKeys: '=?mdSeparatorKeys',