@@ -110,7 +110,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
110
110
compile : function ( tElem , tAttrs ) {
111
111
var tooltipLinker = $compile ( template ) ;
112
112
113
- return function link ( scope , element , attrs ) {
113
+ return function link ( scope , element , attrs , tooltipCtrl ) {
114
114
var tooltip ;
115
115
var tooltipLinkedScope ;
116
116
var transitionTimeout ;
@@ -130,6 +130,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
130
130
tooltip . css ( ttPosition ) ;
131
131
} ;
132
132
133
+ // Set up the correct scope to allow transclusion later
134
+ ttScope . origScope = scope ;
135
+
133
136
// By default, the tooltip is not open.
134
137
// TODO add ability to start tooltip opened
135
138
ttScope . isOpen = false ;
@@ -195,7 +198,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
195
198
196
199
// And show the tooltip.
197
200
ttScope . isOpen = true ;
198
- ttScope . $digest ( ) ; // digest required as $apply is not called
201
+ ttScope . $apply ( ) ; // digest required as $apply is not called
199
202
200
203
// Return positioning function as promise callback for correct
201
204
// positioning after draw.
@@ -339,6 +342,72 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
339
342
} ] ;
340
343
} )
341
344
345
+ // This is mostly ngInclude code but with a custom scope
346
+ . directive ( 'tooltipTemplateTransclude' , [
347
+ '$animate' , '$sce' , '$compile' , '$templateRequest' ,
348
+ function ( $animate , $sce , $compile , $templateRequest ) {
349
+ return {
350
+ link : function ( scope , elem , attrs ) {
351
+ var origScope = scope . origScope ;
352
+
353
+ var changeCounter = 0 ,
354
+ currentScope ,
355
+ previousElement ,
356
+ currentElement ;
357
+
358
+ var cleanupLastIncludeContent = function ( ) {
359
+ if ( previousElement ) {
360
+ previousElement . remove ( ) ;
361
+ previousElement = null ;
362
+ }
363
+ if ( currentScope ) {
364
+ currentScope . $destroy ( ) ;
365
+ currentScope = null ;
366
+ }
367
+ if ( currentElement ) {
368
+ $animate . leave ( currentElement ) . then ( function ( ) {
369
+ previousElement = null ;
370
+ } ) ;
371
+ previousElement = currentElement ;
372
+ currentElement = null ;
373
+ }
374
+ } ;
375
+
376
+ scope . $watch ( $sce . parseAsResourceUrl ( 'content' ) , function ( src ) {
377
+ var thisChangeId = ++ changeCounter ;
378
+
379
+ if ( src ) {
380
+ //set the 2nd param to true to ignore the template request error so that the inner
381
+ //contents and scope can be cleaned up.
382
+ $templateRequest ( src , true ) . then ( function ( response ) {
383
+ if ( thisChangeId !== changeCounter ) { return ; }
384
+ var newScope = origScope . $new ( ) ;
385
+ var template = response ;
386
+
387
+ var clone = $compile ( template ) ( newScope , function ( clone ) {
388
+ cleanupLastIncludeContent ( ) ;
389
+ $animate . enter ( clone , elem ) ;
390
+ } ) ;
391
+
392
+ currentScope = newScope ;
393
+ currentElement = clone ;
394
+
395
+ currentScope . $emit ( '$includeContentLoaded' , src ) ;
396
+ } , function ( ) {
397
+ if ( thisChangeId === changeCounter ) {
398
+ cleanupLastIncludeContent ( ) ;
399
+ scope . $emit ( '$includeContentError' , src ) ;
400
+ }
401
+ } ) ;
402
+ scope . $emit ( '$includeContentRequested' , src ) ;
403
+ } else {
404
+ cleanupLastIncludeContent ( ) ;
405
+ }
406
+ } ) ;
407
+ }
408
+ } ;
409
+ } ] )
410
+
342
411
. directive ( 'tooltipPopup' , function ( ) {
343
412
return {
344
413
restrict : 'EA' ,
0 commit comments