Redirect to a view after successful save in ionic


#1

Hello,

How i redirect to another How to redirect to a another view after successful save ng-submit formafter successful post

.factory('Post', function($resource) {
  return $resource(api/add_new_order',{name: "@name", phone: "@phone", address: "@address",problem: "@problem", device: "@device", price: "@price"});
})
.controller('ContactCtrl', function($scope, Post, Authorization) {
  
  // Get all posts
  $scope.posts = Post.query();
  // Our form data for creating a new post with ng-model
  $scope.postData = {};
  $scope.newPost = function() {
    var post = new Post($scope.postData);
    post.$save();

  }
$scope.issues = {};
$scope.answer = function(){
    console.log($scope.issues.name);

}
$scope.postData = Authorization;
})

#2

Have you test $state.go('your-view-state-name'); ??


#3

Not working with me

.controller('ContactCtrl', function($scope, Post, Authorization) {
  
  // Get all posts
  $scope.posts = Post.query();
  // Our form data for creating a new post with ng-model
  $scope.postData = {};
  $scope.newPost = function() {
    var post = new Post($scope.postData);
    post.$save();

  }
$scope.issues = {};
$scope.answer = function(){
    console.log($scope.issues.name);
}
$scope.postData = Authorization;

$state.go('tab.home');
})

#4

Log the error.
but if you call newPost() it’s clear you don’t transfer to tab.home , move$state.go('tab.home'); to line after post.$save();