我在Angular 2中有一个表单,我试图在其中一个字段模糊时触发表单的(ngSubmit)事件,但使用(blur)事件调用该函数不会传递模型元素
以下是代码:
<form
#phoneForm="ngForm"
(ngSubmit)="addPhone(phoneForm)"
style="width:100%;">
<ion-grid>
<ion-row class="edit-field">
<ion-col col-auto class="field-icon">
<ion-icon name="md-remove-circle"></ion-icon>
</ion-col>
<ion-col col-auto class="field-type">
<select
ngModel
id="phoneType"
name="phoneType"
#phoneType="ngModel">
<option
value="select"
ng-selected="true"
ng-disabled="true" > -- Select -- </option>
<option value="home" >home</option>
<option value="mobile" >mobile</option>
<option value="business" >business</option>
<option value="home fax" >home fax</option>
<option value="work fax" >work fax</option>
<option value="fax">fax</option>
</select>
</ion-col>
<ion-col class="field-input">
<input
type="text"
name="phoneNumber"
name="phoneNumber"
id="phoneNumber"
ngModel
#phoneNumber="ngModel"
placeholder="Phone"
ng-blur="addPhone()">
</ion-col>
</ion-row>
</ion-grid>
</form>
作为一个简单的测试,我在组件中有这个功能:
addPhone(data){
console.log('Hit add phone', data.value);
}
如何提交有关模糊的表单?