angular2-course icon indicating copy to clipboard operation
angular2-course copied to clipboard

basicValidators.ts

Open greglim81 opened this issue 8 years ago • 3 comments

Anyone managed to get the validators in user-form.component.html to work?

greglim81 avatar Sep 20 '16 05:09 greglim81

Of course! The only thing you have to do is to get the control correctly - this still is wrong in the code of mosh!!!

In the template you have to replace the local variable #name anf get the control via the userForm.controls Array: <input [(ngModel)]="user.name" id="name" name="name" formControlName="name" type="text" class="form-control"> <div *ngIf="userForm.controls.name.touched && userForm.controls.name.invalid" class="alert alert-danger">

The same for the others

scheilch avatar Sep 23 '16 10:09 scheilch

Hi scheilch, do you think you can share your code? I think it would just be user-form.component.ts and user-form.component.ts right?

greglim81 avatar Sep 24 '16 00:09 greglim81

I just Shared the snippet but Github don't Show it. Go ahead with accessing the userForm.controls.name instead of the local Variable in the html file. That should work for you.

scheilch avatar Sep 24 '16 08:09 scheilch