Redirect to a different page after POST using AngularJS
Remember to inject the dependency to the controller:
|-- inject!
angular.module('myApp.controllers', []). v
controller('AddressController', function ($scope, $location, $http) {
$http({
method: 'POST',
url: '/addressBook/api/Person',
data: $scope.person,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
}).success(function (data) {
$location.path('/addressBook');
});
});
There should be something listening on that path change, like a $routeProvider
. Is that the case?
If you need a full page reload to that other (server-side) route you might try $window.location.href
.