Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
How can i get the attributes values from a QueryList element with ElementRef or ViewContainer?

I need to get the ID attribute of each item in my QueryList from my carousel.component.ts in order to validate the selected item. Because to certain restrictions of the code that was developed, I cannot pass the value through an @Input from the parent, so I need to obtain it from the child.

This is an example from my code: https://stackblitz.com/edit/angular-1vnbxc-zc9fz8?file=src/app/carousel/carousel.component.ts

Child component property that i need to use to get the items

@ContentChildren(ProductCarouselDirective) slides: QueryList<ProductCarouselDirective>

Child Directive

export class ProductCarouselDirective implements OnInit {

  constructor(
    public templateRef: TemplateRef<any>,
    public viewContainer: ViewContainerRef) { }

    ngOnInit()
  {
    this.viewContainer.createEmbeddedView(this.templateRef)
  }

}

Function that I am using to test options on how to get the ID attribute with elementRef or viewContainer

  private getElementSelect() {
    this.slides.toArray().forEach((elements) => {
      console.log(elements.templateRef.elementRef.nativeElement);
      // console.log(elements.viewContainer);
    });
  }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda