How to get tab and set it as default in angular with angular material Tabs

Published

I have a component inside another big component (parent). The big component has the tabs feature and to access those tabs inside the inner component im doing the following:

document.querySelectorAll('.mat-tab-group');

That above code outputs me an array of length 2 because there is another tab. So to access the last one and set the default tab im doing the following:

const tabs = document.querySelectorAll('.mat-tab-group');
if (tabs.length > 0) {
    tabs[tabs.length - 1]['selectedIndex'] = 3;
} 

But that does nothing. I appreciate any help. Thank you.

Note: I cant touch parent component. Only the inner one.

Source: Angular Material Quesions

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq