From 33eba0e96e1be80c8a33343a1f5da364a5579f13 Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Sun, 2 Nov 2014 11:04:19 -0800 Subject: [PATCH] fix(tooltip): evaluate appendToBody on init This wasn't working properly with the location change code (lines 305-314) because the observe call happens asynchronously after the linking function has completed. Hence, the locationChangeSuccess wasn't being set up unless the global tooltip option's appendToBody option was set to true. --- src/tooltip/tooltip.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index dfed38d87f..3bbf9be9cc 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -64,7 +64,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap * Returns the actual instance of the $tooltip service. * TODO support multiple triggers */ - this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate ) { + this.$get = [ '$window', '$compile', '$timeout', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $document, $position, $interpolate ) { return function $tooltip ( type, prefix, defaultTriggerShow ) { var options = angular.extend( {}, defaultOptions, globalOptions ); @@ -299,9 +299,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap var animation = scope.$eval(attrs[prefix + 'Animation']); scope.tt_animation = angular.isDefined(animation) ? !!animation : options.animation; - attrs.$observe( prefix+'AppendToBody', function ( val ) { - appendToBody = angular.isDefined( val ) ? $parse( val )( scope ) : appendToBody; - }); + var appendToBodyVal = scope.$eval(attrs[prefix + 'AppendToBody']); + appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody; // if a tooltip is attached to we need to remove it on // location change as its parent scope will probably not be destroyed