I have this validation on a field:
<div class="col-lg-6">
STRADA
<input name="street" #street="ngModel" class="form-control" [(ngModel)]="model.Address.Street" required/>
<div *ngIf="street.errors && (street.dirty || street.touched)" class="alert alert-danger">
<div [hidden]="!street.errors.required">
Strada este obligatorie!
</div>
</div>
</div>
How can I access street.errors in the typescript side ?
Thanks in advance.
You can access the Element by using @ViewChild
import { ....., ViewChild } from '@angular/core';
export class YourComponent.... {
@ViewChild('street') streetElement;
private checkElementStatus(): void {
console.log(this.streetElement.errors)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With