2013-11-01 2 views
1

ng-click 이벤트에서 AngularJS의 scrollTo 효과를 구현하려고합니다 (following the example in this Plunkr).anchorscroll()을 사용하여 AngularJS의 요소로 창을 스크롤하는 방법은 무엇입니까?

내가,과 같이 categoryhead 스크롤하기 위해 노력하고있어 :

myApp.controller('FoodCtrl', function ($scope, $http, $location, $anchorScroll) { 

//other stuff 

$scope.loadFood = function(category) { 
//other stuff 

    //Scroll category head to top of page 
    $scope.categoryhead = "#" + category; 
    $location.hash($scope.categoryhead); 
    $anchorScroll(); 

//Ajax load stuff 
}; 
}); 

내가 $의 값이 템플릿에서 인쇄 scope.categoryhead하고 각 요소에 대한 올바른 ID 것을 볼 수있다, 창은 스크롤되지 않습니다. 요소 ID를 $ anchorscroll()에 전달할 때 문제가 있습니까?

Here's my Plunkr

답변

-1

당신은 더 높이 여기에 그 표시되지 스크롤

.scroll{ 
    height: 350px; 
    overflow: auto; 
} 

되어 주어지지 정도로 적용 할 CSS를 놓친

+0

아니, 원래는 .scroll의 높이 및 오버 플로우 설정에 의존하지 않습니다. 제거하면 여전히 작동합니다. – Ila

관련 문제