@@ -1847,18 +1847,26 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1847
1847
if ( interpolateFn ) {
1848
1848
directives . push ( {
1849
1849
priority : 0 ,
1850
- compile : valueFn ( function textInterpolateLinkFn ( scope , node ) {
1851
- var parent = node . parent ( ) ,
1852
- bindings = parent . data ( '$binding' ) || [ ] ;
1853
- // Need to interpolate again in case this is using one-time bindings in multiple clones
1854
- // of transcluded templates.
1855
- interpolateFn = $interpolate ( text ) ;
1856
- bindings . push ( interpolateFn ) ;
1857
- safeAddClass ( parent . data ( '$binding' , bindings ) , 'ng-binding' ) ;
1858
- scope . $watch ( interpolateFn , function interpolateFnWatchAction ( value ) {
1859
- node [ 0 ] . nodeValue = value ;
1860
- } ) ;
1861
- } )
1850
+ compile : function textInterpolateCompileFn ( templateNode ) {
1851
+ // when transcluding a template that has bindings in the root
1852
+ // then we don't have a parent and should do this in the linkFn
1853
+ var parent = templateNode . parent ( ) , hasCompileParent = parent . length ;
1854
+ if ( hasCompileParent ) safeAddClass ( templateNode . parent ( ) , 'ng-binding' ) ;
1855
+
1856
+ return function textInterpolateLinkFn ( scope , node ) {
1857
+ var parent = node . parent ( ) ,
1858
+ bindings = parent . data ( '$binding' ) || [ ] ;
1859
+ // Need to interpolate again in case this is using one-time bindings in multiple clones
1860
+ // of transcluded templates.
1861
+ interpolateFn = $interpolate ( text ) ;
1862
+ bindings . push ( interpolateFn ) ;
1863
+ parent . data ( '$binding' , bindings ) ;
1864
+ if ( ! hasCompileParent ) safeAddClass ( parent , 'ng-binding' ) ;
1865
+ scope . $watch ( interpolateFn , function interpolateFnWatchAction ( value ) {
1866
+ node [ 0 ] . nodeValue = value ;
1867
+ } ) ;
1868
+ } ;
1869
+ }
1862
1870
} ) ;
1863
1871
}
1864
1872
}
0 commit comments