From 4c47b27e0408f5c22a51aec99226bceccea849a2 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 Closes #6175 --- 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 0d78579bf54..01c6e112eb4 100644 --- a/src/components/chips/js/chipsController.js +++ b/src/components/chips/js/chipsController.js @@ -213,7 +213,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.secondaryPlaceholder : this.placeholder; };