I want to redirect to the another page & focus should be on the some DIV with id let's say 'some-div-id'. I tried following
$location.path('/' + $scope.config_path.school + '/' + $routeParams.someUrl + '/#some-div-id') This is working fine but it first change # to %23 Like
/%23some-div-id #If '#' is not already present in the URL /%23some-div-id#some-div-id #If '#' is laready present in the URL /#some-div-id I also tried following
$location.path('/' + $scope.config_path.school + '/' + $routeParams.someUrl + '/').hash('some-div-id') it is creating a proper URL but not scroll down to the DIV with id some-div-id
EDITED
app.run(function($rootScope, $location, $anchorScroll, $routeParams) { $rootScope.$on('$routeChangeSuccess', function(newRoute, oldRoute) { setTimeout(function() { if ($location.hash()) { $anchorScroll($location.hash()); } }); }); }) app.controller('MainCntrl', function($scope, $location, $anchorScroll, $routeParams) { }); Also i tried $location.path & $location.url
$anchorScrolldocs.angularjs.org/api/ng/service/$anchorScroll#!$anchorScrollbut it is not scroll down to the DIV, may be bacuase i am redirecting from one page to other and then using$anchorScroll$anchorScrollservice.