我正在尝试使用action属性创建一个简单的登录表单.这里的问题是从未发送/ login的请求.通过开发工具在DOM中复制和粘贴表单使复制的表单起作用.Angular似乎阻止了表单的默认行为.
这是我的登录表单组件,非常基本:
@Component({
selector: 'my-app',
template: `
<form #f="ngForm" action="/login" method="POST">
Username: <input type="text"required>
<br/>
Password: <input type="password" required>
<br/>
<button type="submit">Login</button>
</form>
`,
directives: [FORM_DIRECTIVES]
})
Run Code Online (Sandbox Code Playgroud)
我也尝试在指令的处理程序中返回true/ 但它也不起作用.falsengSubmit
这是一个说明问题的掠夺者.
任何人都知道如何告诉角度提交表格与行动要求?
angular.2.0.0-Beta.1
你可以做:
<button type="submit" (click)="f.submit()">Login</button>
或者使用标签中的ngNoForm属性form@Thierry Templier建议: