焦点在 Textarea 中时触发事件
Trigger Event When focus out in Textarea
我正在尝试在 textarea 焦点不在时触发一个事件。我也尝试过使用 (blur)。
当我使用 (focusout) 时,该方法被触发。但是 [(ngModel)] 值保存为 [object FocusEvent]
这是我的component.html
div class="form-input">
<textarea class="form-textarea" rows="2" [(ngModel)]="measurementPoint.Comment" (focusout)="updateMeasurementPointComment($event, component.Id, measurementPoint.CompartMeasurementPointId)">
</textarea>
</div>
这是我的component.ts
updateMeasurementPointComment(comment: string, inspectionDetailId: number, compartMeasurementPointId: number) {
this._service.updateMeasurementPointComment(inspectionDetailId, compartMeasurementPointId,comment ).subscribe(r => {
if (r.m_Item1) {
console.log(comment);
this._notify.success('Saved', r.m_Item2);
} else {
this._notify.alert('Couldn\'t Save', r.m_Item2);
console.log(r.m_Item2);
}
}, err => {
console.log(err);
this._notify.alert('Error', 'Unable to update the measurement comment. Please contact support for help. ');
});
}
这是输出--------
只需更改此处的方法....用 [(ngModel)] 值替换 $EVENT。现在它是完美的工作。
谢谢大家。 :)
div class="form-input">
<textarea class="form-textarea" rows="2" [(ngModel)]="measurementPoint.Comment" (focusout)="updateMeasurementPointComment(measurementPoint.Comment, component.Id, measurementPoint.CompartMeasurementPointId)">
</textarea>
</div>
我正在尝试在 textarea 焦点不在时触发一个事件。我也尝试过使用 (blur)。 当我使用 (focusout) 时,该方法被触发。但是 [(ngModel)] 值保存为 [object FocusEvent]
这是我的component.html
div class="form-input">
<textarea class="form-textarea" rows="2" [(ngModel)]="measurementPoint.Comment" (focusout)="updateMeasurementPointComment($event, component.Id, measurementPoint.CompartMeasurementPointId)">
</textarea>
</div>
这是我的component.ts
updateMeasurementPointComment(comment: string, inspectionDetailId: number, compartMeasurementPointId: number) {
this._service.updateMeasurementPointComment(inspectionDetailId, compartMeasurementPointId,comment ).subscribe(r => {
if (r.m_Item1) {
console.log(comment);
this._notify.success('Saved', r.m_Item2);
} else {
this._notify.alert('Couldn\'t Save', r.m_Item2);
console.log(r.m_Item2);
}
}, err => {
console.log(err);
this._notify.alert('Error', 'Unable to update the measurement comment. Please contact support for help. ');
});
}
这是输出--------
只需更改此处的方法....用 [(ngModel)] 值替换 $EVENT。现在它是完美的工作。 谢谢大家。 :)
div class="form-input">
<textarea class="form-textarea" rows="2" [(ngModel)]="measurementPoint.Comment" (focusout)="updateMeasurementPointComment(measurementPoint.Comment, component.Id, measurementPoint.CompartMeasurementPointId)">
</textarea>
</div>