Click here to Skip to main content
15,921,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a controller made in Angular JS and I want to reload the entire webpage on success of a function.

My function is :
moveToBench: function (employeeId) {
            return $http.post(myApp.IndecommBaseUrl + '/Workflow?entityId=' + employeeId + '&nextStateId=' + myApp.state.bench)
                     
        }


Can anyone help me out?

What I have tried:

moveToBench: function (employeeId) {
return $http.post(myApp.IndecommBaseUrl + '/Workflow?entityId=' + employeeId + '&nextStateId=' + myApp.state.bench)
.success(function (data) {
$route.reload();
});
}
Posted
Updated 20-Sep-16 3:11am
Comments
F-ES Sitecore 20-Sep-16 8:26am    
Use a form, that is what it is there for. The internet worked long before javascript existed.

1 solution

if you want to refresh the whole page then use this
JavaScript
$window.location.reload();

note:inject the $window object
 
Share this answer
 
Comments
Member 12332582 21-Sep-16 1:07am    
Will I loose user data (cookies) after this reload? If yes, how can I do a reload without loosing it.
Karthik_Mahalingam 21-Sep-16 1:10am    
Will I loose user data (cookies) after this reload ? No
yes if the cookie life time expires within that period.
Member 12332582 21-Sep-16 1:41am    
Ok, i tried it out...

Im getting error "ReferenceError: $window is not defined"
Member 12332582 21-Sep-16 1:42am    
I injected $window to :

myApp.controller('getEmployeesController', ['$scope','$window', 'employeeServices', 'dataTable', function ($scope,$window, employeeServices, dataTable) {
employeeServices.getEmployees().then(function (result) {
$scope.moveToBench = function (id) {

employeeServices.moveToBench(id);
}

});


}]);
Karthik_Mahalingam 21-Sep-16 1:48am    
remove the $window from here
['$scope','$window',

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900