From b4832c4b551af7e580ed65d9e5aaee1ef9e6c53e Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Mon, 10 Nov 2014 23:59:35 -0800 Subject: [PATCH] fix(tooltip): show correct tooltip on ngRepeat Thanks to @red-0ne for the test case. This commit reverts a1b1ec4fe0f4ddaad343b16edb8434ff1614300c (#2825) . Fixes #2935 --- src/tooltip/test/tooltip.spec.js | 38 ++++++++++++++++++++++++++++++++ src/tooltip/tooltip.js | 3 ++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index 91ebb81f26..350d89a9a4 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -96,6 +96,44 @@ describe('tooltip', function() { tt.trigger( 'mouseleave' ); })); + it('should show correct text when in an ngRepeat', inject( function( $compile, $timeout ) { + + elm = $compile( angular.element( + '' + ) )( scope ); + + scope.items = [ + { name: 'One', tooltip: 'First Tooltip' }, + { name: 'Second', tooltip: 'Second Tooltip' } + ]; + + scope.$digest(); + + var tt_1 = angular.element( elm.find('li > span')[0] ); + var tt_2 = angular.element( elm.find('li > span')[1] ); + + tt_1.trigger( 'mouseenter' ); + tt_1.trigger( 'mouseleave' ); + + $timeout.flush(); + + tt_2.trigger( 'mouseenter' ); + + expect( tt_1.text() ).toBe( scope.items[0].name ); + expect( tt_2.text() ).toBe( scope.items[1].name ); + + tooltipScope = tt_2.scope().$$childTail; + expect( tooltipScope.content ).toBe( scope.items[1].tooltip ); + expect( elm.find( '.tooltip-inner' ).text() ).toBe( scope.items[1].tooltip ); + + tt_2.trigger( 'mouseleave' ); + + })); + it('should only have an isolate scope on the popup', inject( function ( $compile ) { var ttScope; diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 6bb486eeea..89715983a4 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -236,7 +236,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap removeTooltip(); } tooltipLinkedScope = ttScope.$new(); - tooltip = tooltipLinker(tooltipLinkedScope); + tooltip = tooltipLinker(tooltipLinkedScope, angular.noop); + ttScope.$digest(); } function removeTooltip() {