提交没有 (ngSubmit) 的角度表单,以避免 CORS 策略错误



如何提交以下位于角度组件内的表单?单击Send按钮不会触发任何操作。

  <form method="post" action="https://blub.shtml" id="form" name="form" target="_parent">
    <input type="hidden" name="data" value="data" />
    <input type="submit" value="Send" />
  </form>

由于服务器的 CORS 策略,我无法使用(ngSubmit)

事实证明有

一种方法:不使用FormGroupngNoForm允许您通过单击按钮提交表单"non-ajax-way":

  <form ngNoForm
        method="post"
        action="https://blub.shtml"
        target="_parent"
  >
    <input type="hidden" name="data" value="{{data}}">
    <input type="submit" value="Send" />
  </form>

最新更新