【发布时间】:2018-12-30 01:59:58
【问题描述】:
我正在研究一些简单的形式,将其从引导程序转换为材料。
虽然我正在使用 Angular 6,但表单在提交时以旧样式发布(不使用角度表单)
<form method="post" action="http://api.example.com/submit" id="user_form">
<mat-form-field>
<input matInput placeholder="name" name="username">
</mat-form-field>
<mat-form-field>
<mat-select placeholder="user-type" name="usertype">
<mat-option value="type1">type1</mat-option>
<mat-option value="type2">type2</mat-option>
</mat-select>
</mat-form-field>
<button type="submit">submit</button>
</form>
为简单起见,我想保持这种方式,并且在提交此表单时不要使用任何 javascript(没有模板驱动的表单或反应式表单)。
input 非常适合将name 属性添加到imput,当我发布表单(单击提交按钮)时,它按预期发送到服务器。
对于mat-select,此数据不会在发布数据中发送到服务器。
我猜前者是原生的input,其中mat-select是一个组件。
有没有办法让这个工作? (再次,在 TS 端不处理表单 POST)
【问题讨论】: