Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Mostrar explícitamente mensajes de error cuando la página se carga inicialmente
<mat-form-field> <mat-label></mat-label> <input [required] = "isMandatory? true:false" placeholder="Just a placeholder"> <mat-error *ngIf="isMandatory">mandatory field</mat-error> </mat-form-field>

El código anterior funciona bien y muestra el mensaje de error cuando el cuadro de texto se ensucia o se enfoca. Ahora, estoy tratando de mostrar de antemano cuándo se carga la página inicialmente.

 <input [required] = "isMandatory? true:false" placeholder="Just a placeholder" ng-model-options="{ updateOn: 'change blur' }">

Intenté el enfoque anterior sin suerte. ¿Hay alguna forma de mostrar mensajes de error cuando el formulario se carga inicialmente? ¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Una forma de lograr esto sería agregar el siguiente código dentro ngOnInit() :

 ngOnInit(): void { // FormControl or FormGroup initialization code // .................................... this.yourControl.markAsTouched(); // OR, if you want for the whole formGroup (and your're using at leat Angular 8) this.yourFormGroup.markAllAsTouched(); }

Esto debería funcionar y mostrar los errores del lado del cliente (requeridos en su caso) por adelantado.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!