0

I have a form submitted by pressing enter. but when I press enter , the form is submitted but the validators are not run

<form [ngFormModel]="form"  (keyup.enter)="updateApplicationLink()">
   <input  [(ngModel)]="table.labelFR"   ngControl="labelfr">

constructor(fb: FormBuilder) {
  this.form= fb.group({
      labelfr: new Control('', Validators.required)
  });
Florence
  • 1,641
  • 3
  • 13
  • 23
  • works fine, i log validation state of form and it's as expected. `updateApplicationLink(){ console.log(this.form.valid) }` – tchelidze Jun 02 '16 at 11:11
  • ngModel can binds to component property only. maybe this can help http://stackoverflow.com/questions/37583909/angular2-bind-ngmodel-to-a-reference-of-a-property/37583928#37583928 – candidJ Jun 02 '16 at 11:24

1 Answers1

1

try this for required validation:

<input ng-model="labelFR" required>
<h1>{{form.labelFR.$valid}}</h1>
othman.Da
  • 621
  • 4
  • 16