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

123
Visualizações
How can I fetch nodelist with document.querySelectorAll in Angular?

This is a part of an e-commerce app in which customers can select an order and go to checkout. A group of similar buttons that have a data- attribute, with respective extensions to data-something. I am able to implement this well in JavaScript and Html 5. I want to know how to achieve exactly the same using Angular.

    
          <button data-plan="bronze">Select Plan</button>
          <button data-plan="silver">Select Plan</button>
          <button data-plan="gold">Select Plan</button>
          <button data-plan="diamond">Select Plan</button>

Below is JavaScript I wish to implement in Angular,

// Select Plan Logic
    const planButtons = document.querySelectorAll("button[data-plan]");
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

To interact with HTML elements in Angular and have references on them you should use @ViewChild or @ViewChildren decorators. First one is for only one element and second one for more than one.

When using these decorators you should consider ngAfterViewInit lifecycle method in which you can access references to DOM elements. Under the hood, @ViewChild or @ViewChildren are using document.querySelector and document.querySelectorAll.

Learn and read more about them:

https://angular.io/api/core/ViewChild

https://angular.io/api/core/ViewChildren

about 4 years ago · Santiago Trujillo Relatório
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