I'm following this link (https://coursetro.com/posts/code/29/Working-with-Angular-2-Material) to create a header on my website using Angular Material, that provides ready-to-use buttons inside the md-tab-group.
For instance, my head-component html is like this:
<md-tab-group>
    <md-tab label="1">
        <app-1></app-1>
    </md-tab>
    <md-tab label="2">
        <app-2></app-2>
    </md-tab>
</md-tab-group>
Now I can switch between page 1 and page 2 in the same URL.
The problem is that besides that way to navigate between those pages with the same URL, I want to add a button in the body of both pages that has the same functionality.
Because of that particularity, I couldn't use the <a href> or the <a routerLink> because it requires to change the URL.
Because of that, I'm struggling to add a button that does exaclty the same thing as when I click in the md-tab-group words in my header.
If someone knows how to proceed, thank you in advance!
                        
Since you are using tabs, you can use the
selectedIndexproperty provided withmd-tab-group. Add aclickevent to the button in the body, pass the tab index to a function that sets the active tab ofselectedIndex.Here's an example:
html:
ts:
Plunker demo