@@ -101,13 +101,15 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
101
101
102
102
return {
103
103
restrict : 'EA' ,
104
+ controller : angular . noop ,
105
+ controllerAs : 'tooltipCtrl' ,
104
106
scope : {
105
107
title : '@' + prefix + 'Title'
106
108
} ,
107
109
compile : function ( tElem , tAttrs ) {
108
110
var tooltipLinker = $compile ( template ) ;
109
111
110
- return function link ( scope , element , attrs ) {
112
+ return function link ( scope , element , attrs , tooltipCtrl ) {
111
113
var tooltip , tooltipScope ;
112
114
var transitionTimeout ;
113
115
var popupTimeout ;
@@ -125,6 +127,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
125
127
tooltip . css ( ttPosition ) ;
126
128
} ;
127
129
130
+ // Set up the correct scope
131
+ tooltipCtrl . scope = scope . $parent ;
132
+
128
133
// By default, the tooltip is not open.
129
134
// TODO add ability to start tooltip opened
130
135
scope . isOpen = false ;
@@ -225,7 +230,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
225
230
tooltip = tooltipLinker ( tooltipScope , function ( ) { } ) ;
226
231
227
232
// Get contents rendered into the tooltip
228
- scope . $digest ( ) ;
233
+ // Apply is required in order to make it work with rendering templates
234
+ scope . $apply ( ) ;
229
235
}
230
236
231
237
function removeTooltip ( ) {
@@ -309,6 +315,32 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
309
315
} ] ;
310
316
} )
311
317
318
+ . directive ( 'tooltipTemplateTransclude' , [
319
+ '$http' , '$compile' , '$templateCache' ,
320
+ function ( $http , $compile , $templateCache ) {
321
+ return {
322
+ link : function ( scope , elem , attrs ) {
323
+ if ( scope . tooltipCtrl && scope . content ) {
324
+ // TODO: How to solve the problem of pre-loading the template?
325
+ // TODO: Should this be watching for changes in scope.content?
326
+ var templateUrl = scope . content ,
327
+ transcludeScope = scope . tooltipCtrl . scope . $new ( ) ;
328
+ $http . get ( templateUrl , { cache : $templateCache } )
329
+ . then ( function ( response ) {
330
+ elem . html ( response . data ) ;
331
+ $compile ( elem . contents ( ) ) ( transcludeScope ) ;
332
+ } ) ;
333
+
334
+ // Manual destruction because the transclude isn't a descendent of the
335
+ // current scope
336
+ scope . $on ( '$destroy' , function ( ) {
337
+ transcludeScope . $destroy ( ) ;
338
+ } ) ;
339
+ }
340
+ }
341
+ } ;
342
+ } ] )
343
+
312
344
. directive ( 'tooltipPopup' , function ( ) {
313
345
return {
314
346
restrict : 'EA' ,
0 commit comments