0

I use Material Tabs in Angular 2.

How can I change the URL address when clicking on a tab. It is required for history navigation.

5
  • There is an method updateActiveLink, without any example how to use Commented Sep 23, 2017 at 12:28
  • Couldnt you just on (click) trigger a router.navigate('url') ? Commented Sep 23, 2017 at 12:44
  • What parameters pass to click? Commented Sep 23, 2017 at 12:49
  • 1
    I tried this.location.replaceState(path); but I need to modify current route link, not replace fully Commented Sep 23, 2017 at 13:40
  • Nonono dude angular provides a class Router which you can use to change routes. You need to read-up on Angular routing. Commented Sep 23, 2017 at 13:42

1 Answer 1

2

When you use <md-tab-group>, then tab changes are within the same route (=url). If you want the route(=url) to be changed when you click on a different tab, you should use <nav md-tab-nav-bar> in combination with <router-outlet></router-outlet>. This is agnostic to your app's router implementation. (So it works with the standard Angular router.) Read more about this in the official tabs documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.