@@ -185,7 +185,9 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
185
185
return {
186
186
terminal : true ,
187
187
link : function ( scope , element , attrs ) {
188
- var modules = [ ] ;
188
+ var modules = [ ] ,
189
+ embedRootScope ,
190
+ deregisterEmbedRootScope ;
189
191
190
192
modules . push ( [ '$provide' , function ( $provide ) {
191
193
$provide . value ( '$templateCache' , $templateCache ) ;
@@ -212,10 +214,12 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
212
214
}
213
215
} , $delegate ) ;
214
216
} ] ) ;
215
- $provide . decorator ( '$rootScope' , [ '$delegate' , function ( embedRootScope ) {
216
- docsRootScope . $watch ( function embedRootScopeDigestWatch ( ) {
217
+ $provide . decorator ( '$rootScope' , [ '$delegate' , function ( $delegate ) {
218
+ embedRootScope = $delegate ;
219
+ deregisterEmbedRootScope = docsRootScope . $watch ( function embedRootScopeDigestWatch ( ) {
217
220
embedRootScope . $digest ( ) ;
218
221
} ) ;
222
+
219
223
return embedRootScope ;
220
224
} ] ) ;
221
225
} ] ) ;
@@ -227,6 +231,11 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
227
231
}
228
232
} ) ;
229
233
234
+ element . bind ( '$destroy' , function ( ) {
235
+ deregisterEmbedRootScope ( ) ;
236
+ embedRootScope . $destroy ( ) ;
237
+ } ) ;
238
+
230
239
angular . bootstrap ( element , modules ) ;
231
240
}
232
241
} ;
0 commit comments