1

I'm using angular-material and ui-router within an angular-meteor project. I managed to successfully use ui-router with angular-material and everything's working except for one thing: if you notice, angular material tabs have a tiny animation making each tab's content slide from left or right when clicking on the tab. Using ui-router this animation is lost. Is there any way to keep it using ui-router? Thanks beforehand.

3
  • Can you show how do you use your tabs in the views and ui-routes config($stateProvider i mean)? Commented Jan 21, 2016 at 14:25
  • pastebin.com/jERT29BR here. And this is how I link ui-router to each md-tab: pastebin.com/x4MJLfBE I also made my meteor project work in local so you can see: pokerstrazzk.duckdns.org white tabs are using ui-router so animations don't work. Green tabs aren't linked to ui-router so they work. Commented Jan 21, 2016 at 14:41
  • Ok, now my tabs look like this: pastebin.com/s0hfACsj nothing changed though. Commented Jan 21, 2016 at 14:53

2 Answers 2

1

First of all you need to use 'ui-sref' attribute with states in your tabs instead of this pastebin.com/x4MJLfBE 'ui-view' to display your templates from the states.

<md-tabs md-selected="selectedIndex" md-border-bottom md-autoselect>
    <md-tab label="Configuration" ui-sref="admin.configurations"></md-tab>
    <md-tab label="Users" ui-sref="admin.users.list"></md-tab>
    <md-tab label="Songs" ui-sref="admin.songs"></md-tab>
</md-tabs>
<div ui-view></div>

ui-sref it's your states

.state('admin.configurations', {
            url: '/configurations',
            templateUrl: 'app/admin/configurations/configurations.tmpl.html',
            controller: 'ConfigurationsController as ctrl',
        })
.state('admin.users.list', {
            url: '/list',
            templateUrl: 'app/admin/users/users.tmpl.html',
            controller: 'UsersListController as ctrl'
        })

Plus your parent state must be abstract. It means that now you in admin state where you have template with your tabs

.state('admin', {
            url: '/admin',
            templateUrl: 'app/admin/admin.tmpl.html',
            controller: 'AdminController as ctrl'
        })
Sign up to request clarification or add additional context in comments.

3 Comments

Ok, now my tabs look like this: pastebin.com/s0hfACsj nothing changed though.
plus you should always dysplay examples of your code in your questions, because your links, can be lost if someone has the same problem
I used that workaround with $scope.watch, because ui-router doesn't seem to work on md-tab using ui-sref (see here: github.com/angular/material/issues/2344). Plus, it would be even more convenient then if code was tested and working before being posted as an answer
0

Ok I solved this way: it is sufficient avoiding "template" or "templateUrl" inside the router state definition and embed each content inside md-tab itself. Let the router state definition just change the url and everything will work.

1 Comment

I have no idea, how to solve the problem with your solution. Maybe you can give an example?

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.