$ anchorScroll调用路由

时间:2014-07-03 07:44:19

标签: angularjs

我只想滚动到同一页面上的元素,但是当我使用$ anchorScroll服务时,它会调用路径,这就是我在控制器中的内容:

BIControllers.controller('ParentCtrl',['$scope', '$location', '$anchorScroll', 
function ($scope, $location, $anchorScroll, DataService) {

    $scope.showInformation = function () {

        $location.hash('Info');

        $anchorScroll();

    };

}]);

这是锚标记:

<a ng-click="showInformation()">Info</a>

1 个答案:

答案 0 :(得分:0)

<a ng-click="showInformation()" id="Info">Info</a>

使用它。在这里你需要使用id attr通过javascript识别。