@@ -69,51 +69,49 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
69
69
var srcExp = attr . src ,
70
70
scopeExp = attr . scope || '' ,
71
71
autoScrollExp = attr . autoscroll ;
72
- if ( ! element [ 0 ] [ 'ng:compiled' ] ) {
73
- element [ 0 ] [ 'ng:compiled' ] = true ;
74
- return function ( scope , element , attr ) {
75
- var changeCounter = 0 ,
76
- childScope ;
77
-
78
- function incrementChange ( ) { changeCounter ++ ; }
79
- scope . $watch ( srcExp , incrementChange ) ;
80
- scope . $watch ( function ( ) {
81
- var includeScope = scope . $eval ( scopeExp ) ;
82
- if ( includeScope ) return includeScope . $id ;
83
- } , incrementChange ) ;
84
- scope . $watch ( function ( ) { return changeCounter ; } , function ( newChangeCounter ) {
85
- var src = scope . $eval ( srcExp ) ,
86
- useScope = scope . $eval ( scopeExp ) ;
87
-
88
- function clearContent ( ) {
89
- // if this callback is still desired
90
- if ( newChangeCounter === changeCounter ) {
91
- if ( childScope ) childScope . $destroy ( ) ;
92
- childScope = null ;
93
- element . html ( '' ) ;
94
- }
72
+
73
+ return function ( scope , element , attr ) {
74
+ var changeCounter = 0 ,
75
+ childScope ;
76
+
77
+ function incrementChange ( ) { changeCounter ++ ; }
78
+ scope . $watch ( srcExp , incrementChange ) ;
79
+ scope . $watch ( function ( ) {
80
+ var includeScope = scope . $eval ( scopeExp ) ;
81
+ if ( includeScope ) return includeScope . $id ;
82
+ } , incrementChange ) ;
83
+ scope . $watch ( function ( ) { return changeCounter ; } , function ( newChangeCounter ) {
84
+ var src = scope . $eval ( srcExp ) ,
85
+ useScope = scope . $eval ( scopeExp ) ;
86
+
87
+ function clearContent ( ) {
88
+ // if this callback is still desired
89
+ if ( newChangeCounter === changeCounter ) {
90
+ if ( childScope ) childScope . $destroy ( ) ;
91
+ childScope = null ;
92
+ element . html ( '' ) ;
95
93
}
94
+ }
96
95
97
- if ( src ) {
98
- $http . get ( src , { cache : $templateCache } ) . success ( function ( response ) {
99
- // if this callback is still desired
100
- if ( newChangeCounter === changeCounter ) {
101
- element . html ( response ) ;
102
- if ( childScope ) childScope . $destroy ( ) ;
103
- childScope = useScope ? useScope : scope . $new ( ) ;
104
- $compile ( element ) ( childScope ) ;
105
- if ( isDefined ( autoScrollExp ) && ( ! autoScrollExp || scope . $eval ( autoScrollExp ) ) ) {
106
- $anchorScroll ( ) ;
107
- }
108
- scope . $emit ( '$contentLoaded' ) ;
96
+ if ( src ) {
97
+ $http . get ( src , { cache : $templateCache } ) . success ( function ( response ) {
98
+ // if this callback is still desired
99
+ if ( newChangeCounter === changeCounter ) {
100
+ element . html ( response ) ;
101
+ if ( childScope ) childScope . $destroy ( ) ;
102
+ childScope = useScope ? useScope : scope . $new ( ) ;
103
+ $compile ( element . contents ( ) ) ( childScope ) ;
104
+ if ( isDefined ( autoScrollExp ) && ( ! autoScrollExp || scope . $eval ( autoScrollExp ) ) ) {
105
+ $anchorScroll ( ) ;
109
106
}
110
- } ) . error ( clearContent ) ;
111
- } else {
112
- clearContent ( ) ;
113
- }
114
- } ) ;
115
- } ;
116
- }
107
+ scope . $emit ( '$contentLoaded' ) ;
108
+ }
109
+ } ) . error ( clearContent ) ;
110
+ } else {
111
+ clearContent ( ) ;
112
+ }
113
+ } ) ;
114
+ } ;
117
115
}
118
116
}
119
117
} ] ;
0 commit comments