我有3个按钮,两个用于打开日期选择器,一个用于提交,我不明白为什么当我点击日期选择器时,表单被提交...不知道我还能做什么
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
onFindAWhip(form: NgForm){
const value = form.value;
console.log(value);
}
答案 0 :(得分:2)
试试这个:
<button md-raised-button type="button" (click)="pickupTo.open()"></button>