I have a unique component in Angular that I utilize throughout my app. It's a button component which I use by calling
<app-delete-btn></app-delete-btn>
wherever needed.
I tried to set the tabindex="1"
attribute for my component but it didn't work. This attribute helps to define the TAB order for specific HTML elements.
After investigating this issue, it seems that the tabindex
does work, but you need to specify it for both the parent and ALL child components.
So, to make it work, I had to do the following:
- When declaring my custom component in the HTML like
, I included the<app-delete-btn tabindex="1"></app-delete-btn>
tabindex
. - Then, I also added it within the
button
element inside theapp-delete-btn.ts
file under the component -<button tabindex="1">Delete</button>
The challenge here is that since I may reuse that button, I can't add the tabindex
directly within the component as it will be applied everywhere the component is used.
So, my question now is:
Is there a way to assign a tabindex
property to all children (referring to the button declared in the component's HTML) when calling
<app-delete-btn></app-delete-btn>
?