Page refresh issue in angularjs

I have a peculiar problem. I use the anchorScroll service to scroll up the page to show any messages, for example, for error messages or saving successful messages. I implement a function in the action of a save button.

What happens when I first clicked the button, it refreshes the page, and then when I use it again, I get the desired result.

I would like to somehow stop him from refreshing the page for the first time.

This button is outside the form directive, although my form is inside the form tag. $ AnchorScroll enabled

<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();
+4
source share
3 answers

: fooobar.com/questions/19774/..., .

var old = $location.hash();
$location.hash('top');
$anchorScroll();
//reset to old to keep any additional routing logic from kicking in
$location.hash(old);

.

+14

ReloadOnSearch: , @Raulucco, .

$routeProvider
.when('/search', {
           templateUrl : 'views/search.html', reloadOnSearch: false
 })
+3

. , , jQuery. , routeProvider reloadOnSearch false, . .

+1

All Articles