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

291
Views
La propiedad 'controles' no existe en el tipo 'AbstractControl'.ngtsc(2339)

ingrese la descripción de la imagen aquí Obteniendo este problema extraño en mi plantilla, eche un vistazo si se puede resolver. Intenté algunas respuestas relacionadas con esto, pero no obtuve nada.

 ngOnInit(): void { this.signUpForm = new FormGroup({ 'userName': new FormControl(null, Validators.required), 'email': new FormControl(null, [Validators.required, Validators.email]), 'gender': new FormControl('male'), 'hobbies': new FormArray([]) }) } onAddHobby() { const control = new FormControl(null, Validators.required); (<FormArray>this.signUpForm.get('hobbies')).push(control); }
 <div formArrayName="hobbies"> <h4>your hobbies</h4> <button class="btn btn-default" (click)="onAddHobby()">add hobby</button> <div class="form-group" *ngFor=" let hobbyControl of signUpForm.get('hobbies').controls; let i = index " > <input type="text" class="form-control" [formControlName]="i" /> </div> </div>

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

0

La forma más sencilla de resolver:

 let hobbyControl of $any(signUpForm.get('hobbies')).controls;

El compilador se queja porque signUpForm.get('hobbies') devuelve un abstractControl (que no tiene controles), pero como sabe que se trata de un FormArray , puede usar $any() https://angular.io/guide /template-expression-operators#any-type-cast-function

about 4 years ago · Juan Pablo Isaza Report

0

Esto sucede porque el método get() devuelve un AbstractControl , que no tiene la propiedad de controles.

Para resolverlo, puede agregar un captador en la clase para convertir el control en un FormArray

 get hobbies(): FormArray { return this.signUpForm.get('hobbies') as FormArray; }

Y luego use el captador en la plantilla en su lugar como:

 <div class="form-group" *ngFor=" let hobbyControl of hobbies.controls; let i = index " >

Salud

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!