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

Commit 88c94ee

Browse files
nils-wisiolpkozlowski-opensource
authored andcommitted
fix(tooltip): support of custom $interpolate.startSymbol
1 parent 58efec8 commit 88c94ee

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

src/tooltip/test/tooltip.spec.js

+34
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,40 @@ describe('tooltip', function() {
213213

214214
});
215215

216+
describe('tooltipWithDifferentSymbols', function() {
217+
var elm,
218+
elmBody,
219+
scope,
220+
elmScope;
221+
222+
// load the tooltip code
223+
beforeEach(module('ui.bootstrap.tooltip'));
224+
225+
// load the template
226+
beforeEach(module('template/tooltip/tooltip-popup.html'));
227+
228+
// configure interpolate provider to use [[ ]] instead of {{ }}
229+
beforeEach(module( function($interpolateProvider) {
230+
$interpolateProvider.startSymbol('[[');
231+
$interpolateProvider.startSymbol(']]');
232+
}));
233+
234+
it( 'should show the correct tooltip text', inject( function ( $compile, $rootScope ) {
235+
236+
elmBody = angular.element(
237+
'<div><input type="text" tooltip="My tooltip" tooltip-trigger="focus" tooltip-placement="right" /></div>'
238+
);
239+
$compile(elmBody)($rootScope);
240+
$rootScope.$apply();
241+
elmInput = elmBody.find('input');
242+
elmInput.trigger('focus');
243+
244+
expect( elmInput.next().find('div').next().html() ).toBe('My tooltip');
245+
246+
}));
247+
248+
});
249+
216250
describe( 'tooltipHtmlUnsafe', function() {
217251
var elm, elmBody, scope;
218252

src/tooltip/tooltip.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
5555
* Returns the actual instance of the $tooltip service.
5656
* TODO support multiple triggers
5757
*/
58-
this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', function ( $window, $compile, $timeout, $parse, $document, $position ) {
58+
this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate ) {
5959
return function $tooltip ( type, prefix, defaultTriggerShow ) {
6060
var options = angular.extend( {}, defaultOptions, globalOptions );
6161

@@ -92,11 +92,13 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] )
9292
var directiveName = snake_case( type );
9393
var triggers = setTriggers( undefined );
9494

95+
var startSym = $interpolate.startSymbol();
96+
var endSym = $interpolate.endSymbol();
9597
var template =
9698
'<'+ directiveName +'-popup '+
97-
'title="{{tt_title}}" '+
98-
'content="{{tt_content}}" '+
99-
'placement="{{tt_placement}}" '+
99+
'title="'+startSym+'tt_title'+endSym+'" '+
100+
'content="'+startSym+'tt_content'+endSym+'" '+
101+
'placement="'+startSym+'tt_placement'+endSym+'" '+
100102
'animation="tt_animation()" '+
101103
'is-open="tt_isOpen"'+
102104
'>'+

0 commit comments

Comments
 (0)