_this.testFormEl.nativeElement.submit is not a function for Form Post












0















I have a hidden form in a dialog which I want to submit automatically.
HTML Code :



<form #formVal method="POST" [action]="urlvalue">
<p *ngFor="let item of redirectData.RedirectData.Form.Parameter;
let pindex = index;">
<input type="hidden" [name]="item.name" [value]="item.value">
</p>
</ form>


`



In my previous angular 1.5 code I was doing



$timeout(() => {
angular.element('#3DSForm').submit();
}, 100);


and it was working but here in Angular 6 I tried using ViewChild in ngAfteronInit but still no luck I am getting error for native element, I even used ngNoform in my HTML but didn't work out.



@ViewChild('formVal') form: ElementRef;
setTimeout(() => {
this.form.nativeElement.submit();
}, 200);


Kindly suggest what am I missing










share|improve this question



























    0















    I have a hidden form in a dialog which I want to submit automatically.
    HTML Code :



    <form #formVal method="POST" [action]="urlvalue">
    <p *ngFor="let item of redirectData.RedirectData.Form.Parameter;
    let pindex = index;">
    <input type="hidden" [name]="item.name" [value]="item.value">
    </p>
    </ form>


    `



    In my previous angular 1.5 code I was doing



    $timeout(() => {
    angular.element('#3DSForm').submit();
    }, 100);


    and it was working but here in Angular 6 I tried using ViewChild in ngAfteronInit but still no luck I am getting error for native element, I even used ngNoform in my HTML but didn't work out.



    @ViewChild('formVal') form: ElementRef;
    setTimeout(() => {
    this.form.nativeElement.submit();
    }, 200);


    Kindly suggest what am I missing










    share|improve this question

























      0












      0








      0








      I have a hidden form in a dialog which I want to submit automatically.
      HTML Code :



      <form #formVal method="POST" [action]="urlvalue">
      <p *ngFor="let item of redirectData.RedirectData.Form.Parameter;
      let pindex = index;">
      <input type="hidden" [name]="item.name" [value]="item.value">
      </p>
      </ form>


      `



      In my previous angular 1.5 code I was doing



      $timeout(() => {
      angular.element('#3DSForm').submit();
      }, 100);


      and it was working but here in Angular 6 I tried using ViewChild in ngAfteronInit but still no luck I am getting error for native element, I even used ngNoform in my HTML but didn't work out.



      @ViewChild('formVal') form: ElementRef;
      setTimeout(() => {
      this.form.nativeElement.submit();
      }, 200);


      Kindly suggest what am I missing










      share|improve this question














      I have a hidden form in a dialog which I want to submit automatically.
      HTML Code :



      <form #formVal method="POST" [action]="urlvalue">
      <p *ngFor="let item of redirectData.RedirectData.Form.Parameter;
      let pindex = index;">
      <input type="hidden" [name]="item.name" [value]="item.value">
      </p>
      </ form>


      `



      In my previous angular 1.5 code I was doing



      $timeout(() => {
      angular.element('#3DSForm').submit();
      }, 100);


      and it was working but here in Angular 6 I tried using ViewChild in ngAfteronInit but still no luck I am getting error for native element, I even used ngNoform in my HTML but didn't work out.



      @ViewChild('formVal') form: ElementRef;
      setTimeout(() => {
      this.form.nativeElement.submit();
      }, 200);


      Kindly suggest what am I missing







      post angular6






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 21 '18 at 10:08









      poojaguptapoojagupta

      435818




      435818
























          3 Answers
          3






          active

          oldest

          votes


















          1














          You probably have some element called submit.



          Example:



          <input type="hidden" name="submit">



          Rename it to something else, e.g btnSubmit.






          share|improve this answer































            0














            You should call click event for submit button like this,



            <form #formVal method="POST" [action]="urlvalue">
            <div *ngFor="let item of redirectData.RedirectData.Form.Parameter; let pindex = index;">
            <input type="hidden" [name]="item.name" [value]="item.value">
            </div>
            <input type="hidden" name="submit" #submitBtn>
            </ form>


            in ts file



            @ViewChild('submitBtn') submitBtn: ElementRef;



            submitForm() {
            this.submitBtn.nativeElement.click();
            }


            after that call the submitForm() function from where you want to submit the function.






            share|improve this answer































              0














              I was able to achieve it using HTMLFormElement.



              <form ngNoForm name="myForm" id="myForm" [action]="urlvalue" method="POST">
              <button type="submit" class="test" style="visibility: hidden;"></button>
              </form>


              This code in the component.
              const form: HTMLFormElement = document.getElementById('myForm');
              form.submit();






              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51946329%2fthis-testformel-nativeelement-submit-is-not-a-function-for-form-post%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                1














                You probably have some element called submit.



                Example:



                <input type="hidden" name="submit">



                Rename it to something else, e.g btnSubmit.






                share|improve this answer




























                  1














                  You probably have some element called submit.



                  Example:



                  <input type="hidden" name="submit">



                  Rename it to something else, e.g btnSubmit.






                  share|improve this answer


























                    1












                    1








                    1







                    You probably have some element called submit.



                    Example:



                    <input type="hidden" name="submit">



                    Rename it to something else, e.g btnSubmit.






                    share|improve this answer













                    You probably have some element called submit.



                    Example:



                    <input type="hidden" name="submit">



                    Rename it to something else, e.g btnSubmit.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 19 '18 at 10:42









                    markomarko

                    7812925




                    7812925

























                        0














                        You should call click event for submit button like this,



                        <form #formVal method="POST" [action]="urlvalue">
                        <div *ngFor="let item of redirectData.RedirectData.Form.Parameter; let pindex = index;">
                        <input type="hidden" [name]="item.name" [value]="item.value">
                        </div>
                        <input type="hidden" name="submit" #submitBtn>
                        </ form>


                        in ts file



                        @ViewChild('submitBtn') submitBtn: ElementRef;



                        submitForm() {
                        this.submitBtn.nativeElement.click();
                        }


                        after that call the submitForm() function from where you want to submit the function.






                        share|improve this answer




























                          0














                          You should call click event for submit button like this,



                          <form #formVal method="POST" [action]="urlvalue">
                          <div *ngFor="let item of redirectData.RedirectData.Form.Parameter; let pindex = index;">
                          <input type="hidden" [name]="item.name" [value]="item.value">
                          </div>
                          <input type="hidden" name="submit" #submitBtn>
                          </ form>


                          in ts file



                          @ViewChild('submitBtn') submitBtn: ElementRef;



                          submitForm() {
                          this.submitBtn.nativeElement.click();
                          }


                          after that call the submitForm() function from where you want to submit the function.






                          share|improve this answer


























                            0












                            0








                            0







                            You should call click event for submit button like this,



                            <form #formVal method="POST" [action]="urlvalue">
                            <div *ngFor="let item of redirectData.RedirectData.Form.Parameter; let pindex = index;">
                            <input type="hidden" [name]="item.name" [value]="item.value">
                            </div>
                            <input type="hidden" name="submit" #submitBtn>
                            </ form>


                            in ts file



                            @ViewChild('submitBtn') submitBtn: ElementRef;



                            submitForm() {
                            this.submitBtn.nativeElement.click();
                            }


                            after that call the submitForm() function from where you want to submit the function.






                            share|improve this answer













                            You should call click event for submit button like this,



                            <form #formVal method="POST" [action]="urlvalue">
                            <div *ngFor="let item of redirectData.RedirectData.Form.Parameter; let pindex = index;">
                            <input type="hidden" [name]="item.name" [value]="item.value">
                            </div>
                            <input type="hidden" name="submit" #submitBtn>
                            </ form>


                            in ts file



                            @ViewChild('submitBtn') submitBtn: ElementRef;



                            submitForm() {
                            this.submitBtn.nativeElement.click();
                            }


                            after that call the submitForm() function from where you want to submit the function.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 18 '18 at 6:19









                            Umesh PatadiyaUmesh Patadiya

                            377418




                            377418























                                0














                                I was able to achieve it using HTMLFormElement.



                                <form ngNoForm name="myForm" id="myForm" [action]="urlvalue" method="POST">
                                <button type="submit" class="test" style="visibility: hidden;"></button>
                                </form>


                                This code in the component.
                                const form: HTMLFormElement = document.getElementById('myForm');
                                form.submit();






                                share|improve this answer




























                                  0














                                  I was able to achieve it using HTMLFormElement.



                                  <form ngNoForm name="myForm" id="myForm" [action]="urlvalue" method="POST">
                                  <button type="submit" class="test" style="visibility: hidden;"></button>
                                  </form>


                                  This code in the component.
                                  const form: HTMLFormElement = document.getElementById('myForm');
                                  form.submit();






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    I was able to achieve it using HTMLFormElement.



                                    <form ngNoForm name="myForm" id="myForm" [action]="urlvalue" method="POST">
                                    <button type="submit" class="test" style="visibility: hidden;"></button>
                                    </form>


                                    This code in the component.
                                    const form: HTMLFormElement = document.getElementById('myForm');
                                    form.submit();






                                    share|improve this answer













                                    I was able to achieve it using HTMLFormElement.



                                    <form ngNoForm name="myForm" id="myForm" [action]="urlvalue" method="POST">
                                    <button type="submit" class="test" style="visibility: hidden;"></button>
                                    </form>


                                    This code in the component.
                                    const form: HTMLFormElement = document.getElementById('myForm');
                                    form.submit();







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jan 3 at 5:23









                                    poojaguptapoojagupta

                                    435818




                                    435818






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51946329%2fthis-testformel-nativeelement-submit-is-not-a-function-for-form-post%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Monofisismo

                                        Angular Downloading a file using contenturl with Basic Authentication

                                        Olmecas