question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use method calls on click in material2 tabs and tab groups

See original GitHub issue

Question (not an issue): In Bootstrap tabs we have this in our code:

<ul class="nav nav-tabs">
    <li class="active"><a>Start</a></li>
    <li><a (click)="viewmode.setMode1()">mode1</a></li>
    <li><a (click)="viewmode.setMode2()">mode2</a></li>
</ul>

Now this is calling a utterly complicated hack where routing is accomplished with tampering URLs and parameters that I do not dare to touch. There is not much angularic about that code and I dont have time to change it. So I want to let the current strange routing in place, and need to trigger it with method calls from my tabs. Is this possible with material2 tabs?

e.g.:

 <md-tab-group>
      <md-tab (click)="viewmode.setMode1()" label="mode1">
        <h1>Some tab content</h1>
        <p>...</p>
      </md-tab>
 ....

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adamdportcommented, Apr 28, 2017

For those considering the md-tab-nav-bar, be sure to check out 2177 first. It wraps on mobile and looks terrible today.

@andrewseguin is there a way to add click handlers to md-tabs like OP asked so I can make it work until the nav bar gets fixed?

1reaction
andrewseguincommented, Feb 23, 2017

Sounds like you want to look at the nav bar

<nav md-tab-nav-bar>
  <a md-tab-link
     *ngFor="let link of navLinks"
     [active]="isActive">
    {{tabLink.label}}
  </a>
</nav>

See the bottom section of https://material.angular.io/components/component/tabs

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to call a function when a tab is selected in Angular 4 Tabs?
You need to use the selectChange event: <md-tab-group (selectChange)= ...
Read more >
Tabs - Angular Material
Recalculates the tab group's pagination dimensions. WARNING: Calling this method can be very costly in terms of performance. It should be called as ......
Read more >
Share Tab Groups and collaborate in Safari on Mac
You can share a Tab Group and collaborate with people who use iCloud. ... In the Safari app on your Mac, click the...
Read more >
PySimpleGUI
PySimpleGUI User's Manual. Python GUI For Humans - Transforms tkinter, Qt, Remi, WxPython into portable people-friendly Pythonic interfaces. The Call Reference ...
Read more >
Angular Material mat-tab-group - GeeksforGeeks
For this, we need to use a property called mat-align-tabs. If we want to change the theme then we can change it by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found