From dbe9e8171f3069a5eebbe6842fa10e15514edee9 Mon Sep 17 00:00:00 2001 From: Wesley Cho Date: Thu, 28 Jan 2016 05:53:42 -0800 Subject: [PATCH] fix(typeahead): add guard for no $viewValue - Add guard when $viewValue is undefined, and when showHint & min-length 0 is used Closes #5358 Fixes #5357 --- src/typeahead/typeahead.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index b1a405d397..acc7d1df75 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -247,10 +247,11 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap if (showHint) { var firstLabel = scope.matches[0].label; - if (inputValue.length > 0 && firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) { + if (angular.isString(inputValue) && + inputValue.length > 0 && + firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) { hintInputElem.val(inputValue + firstLabel.slice(inputValue.length)); - } - else { + } else { hintInputElem.val(''); } }