After successfully finding a specific element on my Angular app's page, I am attempting to scroll to it. However, despite trying both $window.scrollTo() and window.scrollTo(), the scrolling action is not being executed as expected. My console does log "Scrolled to 565", which indicates that the correct y-position has been identified.
angular.element(document).ready(function () {
var foundDone = 0;
var currOver = 0;
for (var prog in $scope.programs){
var big = $scope.programs[prog];
if(!big.over && foundDone === 0){
foundDone++;
var e = document.getElementsByClassName('programThumbs')[currOver];
var theTop = e.getBoundingClientRect().top;
$window.scrollTo(0, theTop)
console.log("Scrolled to " + theTop)
}
currOver++;
}
});
Could you please provide any insights on what might be going wrong in this code snippet?