document.querySelector in Angular

I have a list where each li has unique data-id.

<ul class="list">
  <li class="list__el"
      *ngFor="let item of cars"
      data-id="{{ item.id }}">
  </li>
</ul>

In JS I would wrote

let myLi = document.querySelector(`.list__el[data-id="${item.id}"]`)

How to correctly rewrite it for Angular?

54 thoughts on “document.querySelector in Angular”

Leave a Comment