diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index 4e6d555ae4..1a068ca479 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -68,6 +68,24 @@ describe('tooltip', function() { expect( tooltipScope.placement ).toBe( 'bottom' ); })); + it('should update placement dynamically', inject( function( $compile, $timeout ) { + scope.place = 'bottom'; + elm = $compile( angular.element( + 'Selector Text' + ) )( scope ); + scope.$apply(); + elmScope = elm.scope(); + tooltipScope = elmScope.$$childTail; + + elm.trigger( 'mouseenter' ); + expect( tooltipScope.placement ).toBe( 'bottom' ); + + scope.place = 'right'; + scope.$digest(); + $timeout.flush(); + expect(tooltipScope.placement).toBe( 'right' ); + })); + it('should work inside an ngRepeat', inject( function( $compile ) { elm = $compile( angular.element( diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 31faa39705..b4f0e11ec6 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -307,6 +307,15 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap positionTooltipAsync(); }); + attrs.$observe( prefix + 'Placement', function () { + if (ttScope.isOpen) { + $timeout(function () { + prepPlacement(); + show()(); + }, 0, false); + } + }); + function prepPopupClass() { ttScope.popupClass = attrs[prefix + 'Class']; }