angular中使用锚点

来源:互联网 发布:高校财经数据库 编辑:程序博客网 时间:2024/05/20 13:38
http://blog.csdn.net/M_killer/article/details/50394254






angular.module('myApp', ['ngRoute'])
    .run(['$anchorScroll', function($anchorScroll) {
        $anchorScroll.yOffset = 50;   
        // 默认向下便宜50px
        // 在此处配置偏移量
    }])


    .controller('View1Ctrl', ['$scope', '$location', '$anchorScroll', function ($scope, $location, $anchorScroll) {
        $scope.demo = function () {
            $location.hash('test');
            $anchorScroll();
            //移动到锚点
        };
    }]);