Mohit
Mohit

Reputation: 2217

How to redirect from One page to Another

I am a .NET developer but newbie in Angular js and PHP, I want to redirect to another page after saving the data. Here is the following code which i had written, what should i do for that

      var url = domain+"/index.php/welcome/insert2?email="+$scope.uemail+"&name="+$scope.uname+"&make="+$scope.umake.id+"&model="+$scope.umodel.id+"&mobile="+$scope.umobile+"&car_reg_no="+$scope.car_regist+"&pincode="+$scope.upincode;
       //$log.log(url);
       $ionicLoading.show();
       $scope.submitData(url).then(function(data){
            $log.log(data);
            $localstorage.set("uid",data);
                           $ionicLoading.hide();
       });
    }

   }; 

Upvotes: 0

Views: 290

Answers (3)

Anil Singh
Anil Singh

Reputation: 4212

You can write your code look like given below code-sample

var url = domain+"/index.php/welcome/insert2?email="+$scope.uemail+"&name="+$scope.uname+"&make="+$scope.umake.id+"&model="+$scope.umodel.id+"&mobile="+$scope.umobile+"&car_reg_no="+$scope.car_regist+"&pincode="+$scope.upincode;
   //$log.log(url);

   $ionicLoading.show();

   $scope.submitData(url).then(function(data){
        $log.log(data);
         $localstorage.set("uid",data);
   })
  .finally(function () {
      $ionicLoading.hide();
      // Set URL here to redirect other page.
     $state.transitionTo('URL');

  });
};

Upvotes: 0

Rodion
Rodion

Reputation: 521

  1. You can use window.location.href = "URL" to redirect browser to another page
  2. Or Angular router if you want redirect to angular page. How to do it depends on what Angular router do you use:

$state.go('app.page') for standard router for example

Upvotes: 0

YatishRaj
YatishRaj

Reputation: 74

you are not using transitionTo method.which is used to do that work. Here is the code snippet you should write after this line

 $localstorage.set("uid",data);

write

 $state.transitionTo('app.pagename');

Check if it works.

Upvotes: 3

Related Questions