I have a simple $http
function in my Angular app that fetches/updates some data on the view when the user clicks a button. Here is the function:
function getData() {
return $http({
method: 'GET',
url: '/some_endpoint.json',
params: params
}).then(function(resp){
if(resp && resp.data) {
$scope.data = resp.data;
// Do some other stuff here
}
});
}
I've noticed that whenever this function is called, the page scrolls back to the top. I want to know how to prevent this undesirable behavior.
I've already tried all the solutions proposed in this question, but none of them have any effect. Additionally, I'd like to avoid having my $http
function or its wrapper function getData
return false
, as suggested here as that would prevent me from chaining additional promise functions to it.