2

我正在研究 Angular JS,其中我有一个模式窗口。它有一个滚动条和一些隐藏元素。只有当用户单击某个按钮时,这些隐藏元素才会可见。所以我想当用户点击那个按钮时滚动条应该自动移动到弹出窗口的底部。为此,我正在使用 Angular JS 的 $anchorScroll 服务。问题是,该服务正在滚动主页而不是弹出窗口。

下面是我的控制器代码:

angular.module('appControllers').controller('ApplicationCtrl',
 ['$scope', '$anchorScroll', '$location','$timeout', 'socket', '$compile', '$window',
 'ModalService', 'MetricService', 'UtilService',
  function($scope, $anchorScroll, $location, DeploymentManagerService,
    $timeout, socket, $compile, $window, ModalService, MetricService, UtilService) {

$scope.showStageSummary:function(arg){

               if($("#"+arg.name).hasClass("hidden")){
                 $("#"+arg.name).removeClass("hidden");
                 gotoAnchor(50);
               }else{
                $("#"+arg.name).addClass("hidden");
              }
            }

$scope.gotoAnchor = function(x) {
            var newHash = 'anchor' + x;
            if ($location.hash() !== newHash) {
              $location.hash('anchor' + x);
            } else {
              $anchorScroll();
            }
        };
});

我希望将此自动滚动应用于我的模态窗口。我怎样才能做到这一点?

4

0 回答 0