From 88c94ee681a9c4d8e464d82c09f8163bbdc0a365 Mon Sep 17 00:00:00 2001 From: Nils Wisiol Date: Mon, 17 Jun 2013 15:29:57 +0200 Subject: [PATCH] fix(tooltip): support of custom $interpolate.startSymbol --- src/tooltip/test/tooltip.spec.js | 34 ++++++++++++++++++++++++++++++++ src/tooltip/tooltip.js | 10 ++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index a9b762c6a9..1198009374 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -213,6 +213,40 @@ describe('tooltip', function() { }); +describe('tooltipWithDifferentSymbols', function() { + var elm, + elmBody, + scope, + elmScope; + + // load the tooltip code + beforeEach(module('ui.bootstrap.tooltip')); + + // load the template + beforeEach(module('template/tooltip/tooltip-popup.html')); + + // configure interpolate provider to use [[ ]] instead of {{ }} + beforeEach(module( function($interpolateProvider) { + $interpolateProvider.startSymbol('[['); + $interpolateProvider.startSymbol(']]'); + })); + + it( 'should show the correct tooltip text', inject( function ( $compile, $rootScope ) { + + elmBody = angular.element( + '
' + ); + $compile(elmBody)($rootScope); + $rootScope.$apply(); + elmInput = elmBody.find('input'); + elmInput.trigger('focus'); + + expect( elmInput.next().find('div').next().html() ).toBe('My tooltip'); + + })); + +}); + describe( 'tooltipHtmlUnsafe', function() { var elm, elmBody, scope; diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 2d4f85b4fa..beda193a73 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -55,7 +55,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) * Returns the actual instance of the $tooltip service. * TODO support multiple triggers */ - this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', function ( $window, $compile, $timeout, $parse, $document, $position ) { + this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate ) { return function $tooltip ( type, prefix, defaultTriggerShow ) { var options = angular.extend( {}, defaultOptions, globalOptions ); @@ -92,11 +92,13 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) var directiveName = snake_case( type ); var triggers = setTriggers( undefined ); + var startSym = $interpolate.startSymbol(); + var endSym = $interpolate.endSymbol(); var template = '<'+ directiveName +'-popup '+ - 'title="{{tt_title}}" '+ - 'content="{{tt_content}}" '+ - 'placement="{{tt_placement}}" '+ + 'title="'+startSym+'tt_title'+endSym+'" '+ + 'content="'+startSym+'tt_content'+endSym+'" '+ + 'placement="'+startSym+'tt_placement'+endSym+'" '+ 'animation="tt_animation()" '+ 'is-open="tt_isOpen"'+ '>'+