Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda