gjerster
gjerster

Reputation: 13

Issue with angular $route.reload();

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();
            });

        };
    }
]);

Upvotes: 0

Views: 15579

Answers (2)

V31
V31

Reputation: 7666

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);
                });                 
            }
        };

    });

Upvotes: 0

sathish salvador
sathish salvador

Reputation: 320

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

Upvotes: 6

Related Questions