2
如何在Angular 2.2.0中顯示錯誤信息,僅當輸入具有類接觸時才顯示?Angular 2僅當輸入類是「ng-touch」時才顯示錯誤消息?
<form #myForm='ngForm' (ngSubmit)='onSubmit(submit)' (submit)="preventDefault($event)">
<input type="text" name="firstName" ngModel required>
<div class="error-mesg"> Name is required </div>
<button type="submit" [disabled]="!myForm.form.valid">
</form>