Angularjs 对于角路由器ui中的某些特定状态,是否可以将AUTCOLL=false

Angularjs 对于角路由器ui中的某些特定状态,是否可以将AUTCOLL=false,angularjs,angular-ui-router,Angularjs,Angular Ui Router,在我的应用程序中,我使用的是autoscroll=“true” 在大多数情况下,这是理想的行为 但是我是否可以为某些特定状态设置autoscroll=false(例如,当内容附加到页面底部时)?使服务名称成为scrollService app.service('scrollService',function(){ var self = this; self.scrollEnabled = false; //default scroll Status self.enab

在我的应用程序中,我使用的是
autoscroll=“true”


在大多数情况下,这是理想的行为


但是我是否可以为某些特定状态设置
autoscroll=false
(例如,当内容附加到页面底部时)?

使服务名称成为scrollService

app.service('scrollService',function(){
    var self = this;
    self.scrollEnabled = false; //default scroll Status
    self.enable = function(){
      self.scrollEnabled = true;
    }
    self.disable = function(){
      self.scrollEnabled = false;
    }

});
//此控制器将是ui视图元素的父控制器

app.contoller('bodyCtrl',function(scrollService){
   var ctrl = this;
ctrl.scrollService = scrollService;

})
//假设此控制器将是当前状态控制器

app.controller('usersCtrl',function(scrollService){
// if i need this state to be auto scroll 
scrollService.enabled();
// if i need to prevent auto-scroll 
scrollService.disable();
})
//因为HTML必须是

<body ng-controller="bodyCtrl as ctrl">
 <ui-view autoscroll="ctrl.scrollService.scrollEnabled" ></ui-view>
</body>

我知道文档说明我可以在
autoscroll
属性中使用表达式,但是否有任何示例说明如何将状态更改与切换autscroll变量结合起来?
<body ng-controller="bodyCtrl as ctrl">
 <ui-view autoscroll="ctrl.scrollService.scrollEnabled" ></ui-view>
</body>