0

If have the following code but $route.reload() does not refresh the page.

testControllers.controller('LogoutController', [
    '$scope', '$http', '$route',
    function($scope, $http, $route) {
        $scope.logout = function() {
            $http.get('/api/authentication/logout').success(function () {
                $route.reload();
            });

        };
    }
]);
gjerster
  • 13
  • 1
  • 1
  • 2
  • 3
    Any errors in console? Note that there is a difference between reloading route and reloading page. If you want to reload whole page you should use `$window.location.reload();` – akn Jul 17 '14 at 08:08

2 Answers2

6

Reloading the page is done by $window.location.reload(); Reloading the route is done by $route.reload();

sathish salvador
  • 320
  • 5
  • 16
0

For the $http call you need to create a factory and then when the data is returned from the factory to the controller you can then reload the route. The format for the factory is:

angular.module('your factory module', [])
    .factory('testFactory', function($http) {
        return {
            urMethod: function(callback) {
                return $http({
                   <ur http call parameters>
                }).
                success(function(data) {
                    callback(data);
                });                 
            }
        };

    });
V31
  • 7,626
  • 3
  • 26
  • 44