From f95fbd78c2beec4fca4c3ce4edbd465bf1ef61c2 Mon Sep 17 00:00:00 2001 From: StefanFeederle Date: Tue, 8 Dec 2015 21:51:25 +0100 Subject: [PATCH] fix(chips): safety check before getting length If the model is not yet filled (ajax?) this functions fails with: TypeError: Cannot read property 'length' of undefined Ported the fix from: https://github.com/sime/ui-select/commit/1edc16b3f4e493844d008bde9a358cef1ae04acf --- src/components/chips/js/chipsController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/chips/js/chipsController.js b/src/components/chips/js/chipsController.js index 71ea1b2f29..243943fb7b 100755 --- a/src/components/chips/js/chipsController.js +++ b/src/components/chips/js/chipsController.js @@ -181,7 +181,7 @@ MdChipsCtrl.prototype.chipKeydown = function (event) { */ MdChipsCtrl.prototype.getPlaceholder = function() { // Allow `secondary-placeholder` to be blank. - var useSecondary = (this.items.length && + var useSecondary = (this.items && this.items.length && (this.secondaryPlaceholder == '' || this.secondaryPlaceholder)); return useSecondary ? this.placeholder : this.secondaryPlaceholder; };