Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 simple form with Action is not working

Tags:

The code given below is not working in my angular html file but if i use this code individually in an html file it works i don't know what i am doing wrong this is just a simple form .

<form action='https://easypaystg.easypaisa.com.pk/easypay/Index.jsf' method='post'>     <input  name='storeId' value='4950'>     <input  name='amount' value='1000'>     <input  name='postBackURL' value='https://easypaystg.easypaisa.com.pk/easypay/Confirm.jsf'>     <input  name='orderRefNum' value='123113'>     <input  name='merchantHashedReq' value='6ohsP8x3PpiaI4oNirWGwjVkyMLP4CbzcH6pZwvu9SViOzx9nLxyR/TtJhwFrxBU686Wf1z22G+TBxuo5QkSscuXp266qQWx8AbGWnLXxG79LHt+5VlD+lH2JkjKO997adwVHH6mGNm8ldtAKkRyf/E92QF5PwhWMjq8i4dlbABIjJxnwPS3x13R/Nbfmlugkz7XpX20DmZ0IhPuGBR95sOpDATIjfW51fuStCVVni4='>     <input  name='autoRedirect' value='0'>     <input  name='paymentMethod' value='CC_PAYMENT_METHOD'>     <input  name='emailAddr' value='[email protected]'>     <input  name='mobileNum' value='0123455500'>     <button type="submit" class="btn btn-success" >Submit</button>     <input type='submit' value='asdasd' class="btn"> </form> 
like image 448
Haroon Aslam Avatar asked May 15 '18 11:05

Haroon Aslam


People also ask

Does every form need an action?

Back in HTML4, the answer would be yes. Nowadays with HTML5, you are not required to specify an action attribute. If you have a form tag without an action attribute then the data will be sent to its own page.

Is form action attribute required?

The form action (attribute) in HTML accepts an argument. The value of the URL should be the URL. A detailed example is given to explain the form action in HTML. The action attribute was used in HTML4, but in HTML5, the action attribute is `no longer required.

How does form action work?

The formaction attribute specifies the URL of the file that will process the input control when the form is submitted. The formaction attribute overrides the action attribute of the <form> element.

Can we add two actions in a form?

Let's learn the steps of performing multiple actions with multiple buttons in a single HTML form: Create a form with method 'post' and set the value of the action attribute to a default URL where you want to send the form data. Create the input fields inside the as per your concern. Create a button with type submit.


2 Answers

You can do it in following way:

<form #form action='https://easypaystg.easypaisa.com.pk/easypay/Index.jsf' method='post'>     ...     <button type="submit" class="btn btn-success" (click)="form.submit()">Submit</button>     ... </form> 
like image 143
Anshuman Jaiswal Avatar answered Sep 19 '22 12:09

Anshuman Jaiswal


Use the ngNoForm attribute as documented. This will prevent all "magic" Angular behavior, and you will be able to submit the form in the native way (with page reload).

So something similar to:

<form ngNoForm action='https://easypaystg.easypaisa.com.pk/easypay/Index.jsf' method='post'>     <input  name='storeId' value='4950'>     ...     <input type='submit' value='asdasd' class="btn"> </form> 
like image 36
PowerKiKi Avatar answered Sep 20 '22 12:09

PowerKiKi