CaribouCode
CaribouCode

Reputation: 14398

Reload page with $route in Angular JS

I've built a login module using Angular JS. After all validation and database checks have been made using $http, if the login is successful, the page needs to reload so the PHP can show the correct content to the user.

I've tried using $route to reload the page, but I just get weird errors like

Error: [$injector:unpr]....

Relevant code:

(function(){
  var app = angular.module('login',[]);

  app.controller('LoginController', function($scope,$http,$route){   

    $scope.loginCheck = function(){       
      $http({
        method  : 'POST',
        data    : $.param($scope.login),
        url     : '/assets/includes/login.php?query=login',
        headers : { 'Content-Type': 'application/x-www-form-urlencoded' } 
      }).success(function(data){   
        if (data == 'success') $route.reload();
      });
    };

  });

})();

Upvotes: 0

Views: 556

Answers (1)

ms87
ms87

Reputation: 17492

Why don't you just do a hard refresh, you want to re-render the server page if I'm not mistaken, a plain old Javascript reload should do it: location.reload();.

Upvotes: 2

Related Questions