文本框验证消息angular 6

时间:2019-03-22 12:09:26

标签: angular6 angular5 angular7 angular-forms

我正在尝试仅以模板驱动形式在angular 7中显示自定义文本框验证错误消息,但无法正常工作。任何人都可以解决此问题?

   <form #modelForm="ngForm">
   <div>

   <custom-input [(ngModel)]='model.firstname' name='firstname' title='First Name'></custom-input>

   <custom-input [(ngModel)]='model.surname' name='surname' title='Surname'></custom-input>

   <button type="submit" class="btn btn-default"
        [disabled]="modelForm.invalid">Submit</button>

  <button type="button" class="btn btn-default"
        (click)="modelForm.resetForm({})">Reset</button>
   </div>

  <div class="submitted-message" *ngIf="modelForm.submitted">
  <p>model has been submitted: {{ modelForm.value.firstname + ' ' + modelForm.value.surname }}</p>
  <button (click)="modelForm.resetForm({})">Add model</button>
   </div>
  </form>

0 个答案:

没有答案