A
A
Alex Krynytskyi2020-11-09 13:12:18
Angular
Alex Krynytskyi, 2020-11-09 13:12:18

How to access an array of elements in Angular?

there is such a code

<div   *ngFor="let text of items ">
            <a class="link_color" href="">{{text .item}}</a>
</div>


Can I somehow get an array of link_color elements?
so that I can somehow manage elements through js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor P., 2020-11-09
@Jeer

You can get confused and assign an ID to the diva, then get its inner html directly in the controller, but this approach is fundamentally wrong.
You have an array of items, through it and exercise control, add the necessary properties. And already through these properties influence html. For example, add a color property and write like this:

<a [ngClass]="text .color" href="">{{text .item}}</a>

I can mess up the syntax, but something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question