Currently, I am utilizing ui-router and attempting to implement automatic scrolling within the controller. However, it seems that anchorScroll function is not working as expected. My assumption is that it may be due to having two '#' symbols in the URL.
For example:
index.php#/initiative/1/commentscroll/4
gets transformed into:
index.php#/initiative/1/commentscroll/4#comment-id-4
Nevertheless, despite the existence of anchors, the scrolling does not occur (and yes, the anchors are indeed present).
Does anyone have any suggestions or ideas on how to resolve this issue?
controllersModule.controller('InitiativeController', ['$http','$timeout','$location','$state','services','$stateParams','$anchorScroll', function($http,$timeout,$location,$state,services,$stateParams,$anchorScroll){
var pk = this;
pk.initiative={};
if($state.current.url.indexOf("/commentscroll/")!=1){
$timeout(function() {
$location.hash('comment-id-'+$stateParams.commentId);
$anchorScroll();
});
}
services.get($stateParams.initiativeId,'initiative','').then(function(data){
pk.initiative=data;
});
function fillScrollId(element,index,array){
if(element.initiative_comment_id===$stateParams.commentId){
element.scrollToMe="yes";
}
if(element.comments.length>0){
element.comments.forEach(fillScrollId);
}
}
}]);