@@ -540,42 +540,37 @@ var ngNonBindableDirective = valueFn({ terminal: true });
540
540
var ngViewDirective = [ '$http' , '$templateCache' , '$route' , '$anchorScroll' , '$compile' ,
541
541
function ( $http , $templateCache , $route , $anchorScroll , $compile ) {
542
542
return {
543
- compile : function ( element , attr ) {
544
- if ( ! element [ 0 ] [ 'ng:compiled' ] ) {
545
- element [ 0 ] [ 'ng:compiled' ] = true ;
546
-
547
- return function ( scope , element , attrs ) {
548
- var changeCounter = 0 ;
543
+ terminal : true ,
544
+ link : function ( scope , element ) {
545
+ var changeCounter = 0 ;
549
546
550
- scope . $on ( '$afterRouteChange' , function ( ) {
551
- changeCounter ++ ;
552
- } ) ;
547
+ scope . $on ( '$afterRouteChange' , function ( ) {
548
+ changeCounter ++ ;
549
+ } ) ;
553
550
554
- scope . $watch ( function ( ) { return changeCounter ; } , function ( newChangeCounter ) {
555
- var template = $route . current && $route . current . template ;
551
+ scope . $watch ( function ( ) { return changeCounter ; } , function ( newChangeCounter ) {
552
+ var template = $route . current && $route . current . template ;
556
553
557
- function clearContent ( ) {
558
- // ignore callback if another route change occured since
559
- if ( newChangeCounter == changeCounter ) {
560
- element . html ( '' ) ;
561
- }
562
- }
554
+ function clearContent ( ) {
555
+ // ignore callback if another route change occured since
556
+ if ( newChangeCounter == changeCounter ) {
557
+ element . html ( '' ) ;
558
+ }
559
+ }
563
560
564
- if ( template ) {
565
- $http . get ( template , { cache : $templateCache } ) . success ( function ( response ) {
566
- // ignore callback if another route change occured since
567
- if ( newChangeCounter == changeCounter ) {
568
- element . html ( response ) ;
569
- $compile ( element ) ( $route . current . scope ) ;
570
- $anchorScroll ( ) ;
571
- }
572
- } ) . error ( clearContent ) ;
573
- } else {
574
- clearContent ( ) ;
561
+ if ( template ) {
562
+ $http . get ( template , { cache : $templateCache } ) . success ( function ( response ) {
563
+ // ignore callback if another route change occured since
564
+ if ( newChangeCounter == changeCounter ) {
565
+ element . html ( response ) ;
566
+ $compile ( element . contents ( ) ) ( $route . current . scope ) ;
567
+ $anchorScroll ( ) ;
575
568
}
576
- } ) ;
577
- } ;
578
- }
569
+ } ) . error ( clearContent ) ;
570
+ } else {
571
+ clearContent ( ) ;
572
+ }
573
+ } ) ;
579
574
}
580
575
} ;
581
576
} ] ;
0 commit comments