Dennis Kiesel Dennis Kiesel - 1 year ago 170
AngularJS Question

Redirect to a different page after POST using Angular

After searching and not coming up with a solution I am posting this code snippet for some help.

$scope.createAddress = function () {
method: 'POST',
url: '/addressBook/api/Person',
data: $scope.person,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}).success(function (data) {

After successfully posting I would like to redirect to a different page. $location.path is not accomplishing this. I have tried $scope.apply() as some others have had success with that. Am I missing something or not understanding what $location is used for? The code is being hit.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download