Redirect to a different page after POST using AngularJS
Remember to inject the dependency to the controller:
|-- inject!angular.module('myApp.controllers', []). vcontroller('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'); });});
in your controller add the $location. like thisEx: app.controller('yourController', function($scope, $location, $http, etc...)then on your $http should be like this.
$http({.... }).success(function(response) { $location.path('/your path')})
but make sure that you must add additional location to your $routeProvider Configuration. something like:
app.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/yournewlocation', { templateUrl: 'yourTemplate/yourpage' }) }])
thats it. well you know what im talking about.