Skip to content

Instantly share code, notes, and snippets.

@codedcontainer
Created October 19, 2016 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codedcontainer/a84e0778176229b2e42d33edc56f378b to your computer and use it in GitHub Desktop.
Save codedcontainer/a84e0778176229b2e42d33edc56f378b to your computer and use it in GitHub Desktop.
Allows for the use of anchor bookmark links.
<a href="/#/:policy.html/?scrollTo=scope" target="_self">Link</a>
<h2 id="scope">Scope</h2>
angular.module('main').controller('policy',['$scope','$rootScope', '$location', '$anchorScroll', '$routeParams',
function($scope, $rootScope, $location, $anchorScroll, $routeParams){
$rootScope.$on('$routeChangeSuccess', function(newRoute, oldRoute){
$location.hash($routeParams.scrollTo);
$anchorScroll();
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment