[英]form is submitted when I open the datepicker angular material
I have 3 buttons, two to open the datepicker and one to submit, I don't understand why when I click on the datepicker the form is submitted... dont know what else can I do 我有3个按钮,其中两个打开日期选择器,一个提交,我不明白为什么当我单击日期选择器时提交了表单...不知道我还能做什么
home.component.html home.component.html
<form (ngSubmit)="onSubmit(f)" #f="ngForm" >
<span class="from">
<button md-raised-button (click)="pickup.open()" ></button>
<input [mdDatepicker]="pickup"
name="pickup"
ngModel>
<md-datepicker touchUi="true" #pickup></md-datepicker>
</span>
<span class="to">
<button md-raised-button (click)="pickupTo.open()"></button>
<input [mdDatepicker]="pickupTo"
placeholder="DD/MM/YYYY"
name="pickupTo"
ngModel>
<md-datepicker touchUi="true" #pickupTo></md-datepicker>
</span>
<button type="submit">Submit</button>
</form>
home.component.ts home.component.ts
onFindAWhip(form: NgForm){
const value = form.value;
console.log(value);
}
尝试这个:
<button md-raised-button type="button" (click)="pickupTo.open()"></button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.