From 5ffae83d664af738c17b3f89e64e048a9d119590 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Fri, 26 Jul 2013 19:35:39 +0200 Subject: [PATCH] feat(typeahead): expose index to custom templates Closes #699 --- src/typeahead/test/typeahead.spec.js | 4 ++-- src/typeahead/typeahead.js | 1 + template/typeahead/typeahead-popup.html | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index b586e3e83c..f942ed909e 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -232,14 +232,14 @@ describe('typeahead tests', function () { it('should support custom templates for matched items', inject(function ($templateCache) { - $templateCache.put('custom.html', '

{{ match.label }}

'); + $templateCache.put('custom.html', '

{{ index }} {{ match.label }}

'); var element = prepareInputEl("
"); var inputEl = findInput(element); changeInputValueTo(element, 'Al'); - expect(findMatches(element).eq(0).find('p').text()).toEqual('Alaska'); + expect(findMatches(element).eq(0).find('p').text()).toEqual('0 Alaska'); })); }); diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 2e864f01e0..4274b0a00c 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -284,6 +284,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) return { restrict:'E', scope:{ + index:'=', match:'=', query:'=' }, diff --git a/template/typeahead/typeahead-popup.html b/template/typeahead/typeahead-popup.html index f0efda19fa..69707cefe5 100644 --- a/template/typeahead/typeahead-popup.html +++ b/template/typeahead/typeahead-popup.html @@ -1,5 +1,5 @@ \ No newline at end of file