How to open a FormPost url within the ionic app

353 Views Asked by At

home.ts

<form  (ngSubmit)="onSubmit()"  [formGroup]="onlinepaymentForm" action="https://www.viarchtechnologies.com/projects/coolmanz/ws/onlinepaymentRequest" target="_blank" method="POST" #form >
    <ion-list>
        <ion-item class="item item-trns text-center" >
            <ion-label  color="whitee">Amount </ion-label>
            <ion-input type="number" [readonly]='true'  
formControlName="cashamount2" name="amount" value="{{cashamount}}"></ion-input>
        </ion-item>
   <ion-list>
</form>

The post URL is a controller function, from the controller function we open an external URL in a new tab. It is working well when tested with browser. But the URL is not opening in mobile device. How to achieve the same using ionic?

1

There are 1 best solutions below

0
Shehryar Ali On

You can use ionic native plugin - In App Browser https://ionicframework.com/docs/native/in-app-browser/ , not sure if routing into that would resolve the actual problem, as it looks like its for payment.

If you want to pass value from ionic application to the external page you must pass the value using URL like http://html.net/page.php?paramOne=1254&paramTwo=ABC and you can get that value using $_GET['paramOne'] in PHP or else other server-side language.

or you can post the whole json object and fetch as $rawData = file_get_contents("php://input"); check this example; https://forum.ionicframework.com/t/login-authentication-in-ionic-2-with-php-file/53994/4

Also, do check payment plugins on cordova as they have, Like paypal --> they are providing a good api and a cordova-plugin.