Hey,
I’m not 100% sure I implemented my field validator (without form) correctly (using Ionic 2 RC.1).
Do someone see a mistake there?
In my ts file:
telFormGroup: FormGroup;
constructor(private formBuilder: FormBuilder) {
this.telFormGroup = new FormGroup({
'telValidator': new FormControl('', Validators.required)
});
}
In my html file:
<ion-list [formGroup]="telFormGroup">
<ion-item>
<ion-icon name="call" item-left></ion-icon>
<ion-input type="tel" [(ngModel)]="myTelNumber" formControlName="telValidator"></ion-input>
</ion-item>
<ion-item>
<ion-textarea rows="6" [(ngModel)]="anotherFieldIDontWantToValidate" [ngModelOptions]="{standalone: true}"></ion-textarea>
</ion-item>
</ion-list>
Seems to be ok because when I empty or fill the field I see the classes “ng-valid” and “ng-invalid” changing on it … but I didn’t found a clear tutorial article about that, just wanted to be sure I didn’t built something wrong or with a bad practice.
Thx in advance for your feedback