diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js
index 1bc4e2e69b..c068377f17 100644
--- a/src/tooltip/test/tooltip.spec.js
+++ b/src/tooltip/test/tooltip.spec.js
@@ -309,6 +309,26 @@ describe( '$tooltipProvider', function() {
expect( elmBody.children().length ).toBe( 1 );
expect( $body.children().length ).toEqual( bodyLength + 1 );
}));
+
+ it('should close on location change', inject( function( $rootScope, $compile) {
+
+ elmBody = angular.element(
+ '
Selector Text
'
+ );
+
+ scope = $rootScope;
+ $compile(elmBody)(scope);
+ scope.$digest();
+ elm = elmBody.find('span');
+ elmScope = elm.scope();
+
+ elm.trigger( 'mouseenter' );
+ expect( elmScope.tt_isOpen ).toBe( true );
+
+ scope.$broadcast('$locationChangeSuccess');
+ scope.$digest();
+ expect( elmScope.tt_isOpen ).toBe( false );
+ }));
});
describe( 'triggers', function() {
diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js
index 0f1cf4b9ac..1e137f97bf 100644
--- a/src/tooltip/tooltip.js
+++ b/src/tooltip/tooltip.js
@@ -266,6 +266,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
element.bind( triggers.hide, hideTooltipBind );
}
});
+
+ //if a tooltip is attached to we need to remove it on location change
+ if ( options.appendToBody ) {
+ scope.$on('$locationChangeSuccess', hide);
+ }
}
};
};
@@ -296,7 +301,4 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
.directive( 'tooltipHtmlUnsafe', [ '$tooltip', function ( $tooltip ) {
return $tooltip( 'tooltipHtmlUnsafe', 'tooltip', 'mouseenter' );
-}])
-
-;
-
+}]);