-1

How can achieve this in angular 7? how can submit this post action url in angular?

<form method="post" action="https://securegw- 
stage.paytm.in/order/process" name="paytm">
     <table border="1">
        <tbody>
           <input type="hidden" name="MID" value="YOUR_MID_HERE">
        </tbody>
     </table>
     <script type="text/javascript">
        document.paytm.submit();
     </script>
  </form>

Please help... thank you...

5
  • What do you want to achieve ? Send the form when page is loaded ? Commented Jul 18, 2019 at 12:23
  • yes, i want to call submit event on page load Commented Jul 18, 2019 at 12:24
  • I think you can use ReactiveForm provided by angular angular.io/guide/reactive-forms Commented Jul 18, 2019 at 12:25
  • how can i call this "<script type="text/javascript"> document.paytm.submit(); </script>" in angular using Reactive forms? Commented Jul 18, 2019 at 12:26
  • You cannot do that. You should not try to access dom element from angular context outside of it Commented Jul 18, 2019 at 12:34

1 Answer 1

1

Can you try with selecting form in Component then call submit on nativeElement ?

@ViewChild('paytmForm', { read: ElementRef }) paytmForm: ElementRef; 

ngAfterContentInit() {
   this.paytmForm.nativeElement.submit()
}

In template add #paytmForm on form element

<form method="post" action="https://securegw- 
stage.paytm.in/order/process" name="paytm" #paytmForm >
...
</form>
Sign up to request clarification or add additional context in comments.

7 Comments

thank you so much... i already tried this but didn't worked because i was called "this.paytmForm.nativeElement.submit()" just after dynamic form creation... now i tried dynamic form on page load then i got this... Thank you so much "ngAfterContentInit()"
You should read more about angular component lifecycle : angular.io/guide/lifecycle-hooks It will help you for a lot of things ;)
how can done this with reactive forms? please tell me if you have any idea?
Not sure you can do exactly what you want. What you can do is get form value then send those values with httpClient
but i tried using httpclient also but it is not responding as submit()
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.