66 * @requires $compile
77 * @requires $controller
88 * @requires $injector
9- * @requires $anchorScroll
109 *
1110 * @restrict ECA
1211 *
1312 * @description
14- * The ui-view directive tells $state where to place your templates.
13+ * The ui-view directive tells $state where to place your templates.
1514 * A view can be unnamed or named.
1615 *
1716 * @param {string } ui-view A view name.
1817 */
19- $ViewDirective . $inject = [ '$state' , '$compile' , '$controller' , '$injector' , '$anchorScroll ' ] ;
20- function $ViewDirective ( $state , $compile , $controller , $injector , $anchorScroll ) {
18+ $ViewDirective . $inject = [ '$state' , '$compile' , '$controller' , '$injector' , '$uiViewScroll ' ] ;
19+ function $ViewDirective ( $state , $compile , $controller , $injector , $uiViewScroll ) {
2120 var $animator = $injector . has ( '$animator' ) ? $injector . get ( '$animator' ) : false ;
2221 var viewIsUpdating = false ;
2322
@@ -31,6 +30,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
3130 var viewScope , viewLocals ,
3231 name = attr [ directive . name ] || attr . name || '' ,
3332 onloadExp = attr . onload || '' ,
33+ autoscrollExp = attr . autoscroll ,
3434 animate = $animator && $animator ( scope , attr ) ,
3535 initialView = transclude ( scope ) ;
3636
@@ -121,9 +121,9 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
121121 viewScope . $emit ( '$viewContentLoaded' ) ;
122122 if ( onloadExp ) viewScope . $eval ( onloadExp ) ;
123123
124- // TODO: This seems strange, shouldn't $anchorScroll listen for $viewContentLoaded if necessary?
125- // $anchorScroll might listen on event...
126- $anchorScroll ( ) ;
124+ if ( ! angular . isDefined ( autoscrollExp ) || ! autoscrollExp || scope . $eval ( autoscrollExp ) ) {
125+ $uiViewScroll ( element ) ;
126+ }
127127 }
128128 } ;
129129 }
0 commit comments