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

113
Views
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 answers
Answer question

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 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!