Angular2: how to post+redirect form with action on external site

前端 未结 2 1357
有刺的猬
有刺的猬 2021-01-05 11:56

I have a form on an Angular2 webpage.

When I hit submit on the form, I\'d like the equivalent of \" method=\"post\".....> to happen.

That is, the action scr

相关标签:
2条回答
  • 2021-01-05 12:02

    I use the pure Angular JS html to implement this requirement.

    <form ngNoForm action="https://your_url" target="_blank" method="POST">
      <input hidden name='backEndUrl' [(ngModel)]="parameters['backEndUrl']">
    
      <input hidden name='bankNumber' [(ngModel)]="parameters['bankNumber']">
      ...
      <input hidden name='version' [(ngModel)]="parameters['version']">
      <div class="container text-center mt-10">
      <button class="btn-primary" type="submit" onclick="submit()">send</button>
     </div>
    </form>
    
    0 讨论(0)
  • 2021-01-05 12:21

    Thanks to the angular2-forms tag which showed up as an option when I posted this, I think I have found the answer at Angular2 ngNoForm and also do angular form validation

    There is a (rather undocumented) option on ngForm "ngNoForm" which removes the automatic ngForm handling from this specific form. This gives me back the standard use of the Submit button, and gets the behaviour I need.

    0 讨论(0)
提交回复
热议问题