Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

ngScrollSpy with ng-route #6

@cyrusn

Description

@cyrusn

Hi, I am using angular-route together with ngScrollSpy, but find that the hash link won't work with angular-route, I try to use this link to solve the problem, and It seems work too, but want to see if there is another better method.
Here is what I added in ngScrollSpy.js

// ln: 497
// markup += '<a href="#' + $location.path() +'/#'+ item.link + '">';
      markup += '<a href="" ng-click="scrolltoHref(' + "'" +item.link + "'" +')">';

and add a controller to the directive

    controller: function ($scope) {
      $scope.scrolltoHref = function(id){
        $location.hash(id);
        $anchorScroll();
      };
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions