I have a peculiar problem .I am using anchorScroll service to scroll the page to top to show any messages,like for error or save success messages. I am implementing the function in save button action.
What happens here that when I hit the button first time, it refreshes the page and then when I use it again ,I am getting the required result.
I would like to somehow stop it from refreshing the page first time around.
This button is outside the form directive,although my form is inside form tag. Included $anchorScroll service
<a id="top"></a> at the top of my HTML page.
if(data.validateError==true )
{
$scope.saveSuccessfull=false;
$scope.wrongInputError=true;
$scope.negErrorMessage=false;
$scope.loaderDiv=false;
$location.hash('top');
// call $anchorScroll()
$anchorScroll();