Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在angularjs中滚动到div_Javascript_Html_Angularjs_Scroll_Mean - Fatal编程技术网

Javascript 如何在angularjs中滚动到div

Javascript 如何在angularjs中滚动到div,javascript,html,angularjs,scroll,mean,Javascript,Html,Angularjs,Scroll,Mean,当我点击一个按钮时,我试图滚动到我的标签栏 我的html(选项卡) 到目前为止这还不错,但我的身高是固定的。有谁能建议我如何直接滚动到div。谢谢。这是Angular的一项特别服务,AnchorScroll 以下是角度文档中的一个示例: <div id="scrollArea" ng-controller="ScrollController"> <a ng-click="gotoBottom()">Go to bottom</a> <a id="

当我点击一个按钮时,我试图滚动到我的标签栏

我的html(选项卡)


到目前为止这还不错,但我的身高是固定的。有谁能建议我如何直接滚动到
div
。谢谢。

这是Angular的一项特别服务,AnchorScroll

以下是角度文档中的一个示例:

<div id="scrollArea" ng-controller="ScrollController">
  <a ng-click="gotoBottom()">Go to bottom</a>
  <a id="bottom"></a> You're at the bottom!
</div>

angular.module('anchorScrollExample', [])
.controller('ScrollController', ['$scope', '$location', '$anchorScroll',
  function($scope, $location, $anchorScroll) {
    $scope.gotoBottom = function() {
      // set the location.hash to the id of
      // the element you wish to scroll to.
      $location.hash('bottom');

      // call $anchorScroll()
      $anchorScroll();
    };
  }]);

倒下
你在底部!
角度模块('anchorScrollExample',[])
.controller('ScrollController'、['$scope'、'$location'、'$anchorScroll',
功能($scope、$location、$anchorScroll){
$scope.gotoBottom=函数(){
//将location.hash设置为的id
//要滚动到的元素。
$location.hash('bottom');
//致电$anchorScroll()
$anchorScroll();
};
}]);

试试这个代码

$(“#上移”)。单击(函数(){
$(“html,body”).stop().animate({
scrollTop:$(“#制表符”).offset().top-40
}“500”、“线性”);
});
#选项卡{
高度:900px;
背景色:#ccc;
}
#上移{
位置:固定;
字体大小:24px;
底部:25px;
右:25px;
高度:10px;
宽度:10px;
颜色:红色;
}

---这里的所有代码--
向上的

您应该重命名“如何使用angularJS和jQuery滚动到div”这是用于滚动到目的地的官方文档
  function ScrollTopForTabs(){
    $timeout(function () {
         $('html, body').animate({
            scrollTop: 650
        }, 1000);
    }, 1000);
  }
<div id="scrollArea" ng-controller="ScrollController">
  <a ng-click="gotoBottom()">Go to bottom</a>
  <a id="bottom"></a> You're at the bottom!
</div>

angular.module('anchorScrollExample', [])
.controller('ScrollController', ['$scope', '$location', '$anchorScroll',
  function($scope, $location, $anchorScroll) {
    $scope.gotoBottom = function() {
      // set the location.hash to the id of
      // the element you wish to scroll to.
      $location.hash('bottom');

      // call $anchorScroll()
      $anchorScroll();
    };
  }]);