diff --git a/src/common.js b/src/common.js
index efc7a5b9f..aa3d1edd4 100644
--- a/src/common.js
+++ b/src/common.js
@@ -132,6 +132,7 @@ var uis = angular.module('ui.select', [])
}
return function(matchItem, query) {
+ matchItem = String(matchItem);
return query && matchItem ? matchItem.replace(new RegExp(escapeRegexp(query), 'gi'), '$&') : matchItem;
};
})
diff --git a/test/select.spec.js b/test/select.spec.js
index 2ba86fb2a..381d47ddf 100644
--- a/test/select.spec.js
+++ b/test/select.spec.js
@@ -929,6 +929,25 @@ describe('ui-select tests', function() {
expect(scope.selection.selected).toBe('Samantha');
});
+ it('should highlight matched value correctly when it is a number', function() {
+ var el = compileTemplate(
+ ' \
+ {{$select.selected.age}} \
+ \
+ \
+ \
+ '
+ );
+ openDropdown(el);
+ setSearchText(el, '43');
+
+ var choices = $(el).find('.ui-select-choices-row');
+ expect(choices.length).toEqual(1);
+
+ clickItem(el, '43');
+ expect(scope.selection.selected).toBe(43);
+ });
+
it('should invoke select callback on select', function () {
scope.onSelectFn = function ($item, $model, $label) {