Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit b4832c4

Browse files
committedNov 11, 2014
fix(tooltip): show correct tooltip on ngRepeat
Thanks to @red-0ne for the test case. This commit reverts a1b1ec4 (#2825) . Fixes #2935
1 parent 35d0cc1 commit b4832c4

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed
 

Diff for: ‎src/tooltip/test/tooltip.spec.js

+38
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,44 @@ describe('tooltip', function() {
9696
tt.trigger( 'mouseleave' );
9797
}));
9898

99+
it('should show correct text when in an ngRepeat', inject( function( $compile, $timeout ) {
100+
101+
elm = $compile( angular.element(
102+
'<ul>'+
103+
'<li ng-repeat="item in items">'+
104+
'<span tooltip="{{item.tooltip}}">{{item.name}}</span>'+
105+
'</li>'+
106+
'</ul>'
107+
) )( scope );
108+
109+
scope.items = [
110+
{ name: 'One', tooltip: 'First Tooltip' },
111+
{ name: 'Second', tooltip: 'Second Tooltip' }
112+
];
113+
114+
scope.$digest();
115+
116+
var tt_1 = angular.element( elm.find('li > span')[0] );
117+
var tt_2 = angular.element( elm.find('li > span')[1] );
118+
119+
tt_1.trigger( 'mouseenter' );
120+
tt_1.trigger( 'mouseleave' );
121+
122+
$timeout.flush();
123+
124+
tt_2.trigger( 'mouseenter' );
125+
126+
expect( tt_1.text() ).toBe( scope.items[0].name );
127+
expect( tt_2.text() ).toBe( scope.items[1].name );
128+
129+
tooltipScope = tt_2.scope().$$childTail;
130+
expect( tooltipScope.content ).toBe( scope.items[1].tooltip );
131+
expect( elm.find( '.tooltip-inner' ).text() ).toBe( scope.items[1].tooltip );
132+
133+
tt_2.trigger( 'mouseleave' );
134+
135+
}));
136+
99137
it('should only have an isolate scope on the popup', inject( function ( $compile ) {
100138
var ttScope;
101139

Diff for: ‎src/tooltip/tooltip.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
236236
removeTooltip();
237237
}
238238
tooltipLinkedScope = ttScope.$new();
239-
tooltip = tooltipLinker(tooltipLinkedScope);
239+
tooltip = tooltipLinker(tooltipLinkedScope, angular.noop);
240+
ttScope.$digest();
240241
}
241242

242243
function removeTooltip() {

0 commit comments

Comments
 (0)
This repository has been archived.