3

How can I access an element in my component template from my js code?
Suppose I have many components with this template:

<div style="width: inherit; height: inherit;">
    <img class="elem"> </img>
</div>

and I want each component's controller to access its own img - how can I do it?

1 Answer 1

1

You can inject $element into your component controller:

componetnController($element) {
    let img = $element.find('img');
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.