6

The TabControl is visible when the app starts but...

When I click on a tab NO content is visible

What do I wrong?

I use the latest angularJS material design 0.9.4.

   $urlRouterProvider.otherwise("");
      $stateProvider

          .state("main",
          {
            abtract: true,
            url: '',
            views: {
              'content@': {
                templateUrl: '../app/views/administration/administration.html',
                controller: 'AdministrationController'
              }
            }
          })
          .state('main.settings', {
            url: '/settings',
            views: {
              'settings@main': {
                templateUrl: "../app/views/administration/settings.html",
                controller: 'GlobalConfigurationController'
              }
            }
          })
          .state('main.schoolyears', {
            url: '/schoolyears',
            views: {
              'schoolyears@main': {
                templateUrl: "../app/views/schoolyear/schoolyears.html",
                controller: 'SchoolyearsController'
              }
            }
          });

HTML

<div layout-fill layout="column">
  <div ng-include="'app/components/navbar/navbar.html'"></div>
  <div id="content" layout="column" layout-padding>

    <md-tabs md-stretch-tabs="always" class="md-primary md-hue-2">

      <md-tab label="Schoolyears" ui-sref="main.schoolyears" md-active="$state.is('main.schoolyears')">
        <md-tab-body ui-view="schoolyears" layout="vertical" layout-fill></md-tab-body>
      </md-tab>

      <md-tab label="settings" ui-sref="main.settings" md-active="$state.is('main.settings')">
         <md-tab-body ui-view="settings" layout="vertical" layout-fill></md-tab-body>
      </md-tab>

    </md-tabs>
  </div>
</div>
6
  • Can you post the code where you are sourcing the controllers with <script tag? Commented May 23, 2015 at 17:58
  • you want the controllers code? Or know wether I include the controller in the index.html? Commented May 23, 2015 at 18:42
  • I have no error in the browser console. Thus all files are included. All 3 controllers are empty with no code of mine. They also need no code to make the tab work. This is just a router/state and html problem. Commented May 23, 2015 at 18:54
  • ok. in that case, when you click on schoolyears tab, can you tell if schoolyears,html is getting called? via console? Commented May 23, 2015 at 19:10
  • there is NO output in the console. Commented May 23, 2015 at 20:27

1 Answer 1

5

Update: the use of ui-sref and md-tabs was fixed in Angular Material 0.10.0

A workaround has been posted on github, on the previous known md-tab issue:

There's a plunker with the workaround (it seems to work without the views):

  $stateProvider
      .state('tabs', {
        abstract: true,
        url: '/tabs',
        templateUrl: 'tabs.html',
        onEnter: function() { console.log("enter tabs.html"); } })

      .state('tabs.tab1', {
        url: '/tab1',
        onEnter: function() { console.log("enter tab1.html"); },
        controller: function($scope) {

        },
        templateUrl: 'tab1.html'
      })
      .state('tabs.tab2', {
        url: '/tab2',
        onEnter: function() { console.log("enter tab2"); },
        controller: function($scope) {

        },
        templateUrl: 'tab2.html'
      });
Sign up to request clarification or add additional context in comments.

7 Comments

I know this is ond question, but I noticed that there is still one bug in Your Plunker. When You hit back arrow in browser tab content changes from tab 2 to tab 1 but tab 2 is still selected (there is red line below tab 2 when content says tab 1). Can this be fixed?
Please don't use that plunker anymore. It was made with an old version of Angular Material that needed the workaround to play nice with ui-router. It's not the case anymore.
You can see it working fine without the "span" hack here: plnkr.co/edit/psinbetM1CUBqIxuL1yq
Thank You for reply, but in Your latest Plunker when clicking back in browser tab 1 isn't getting selected. I've tweaked Your code a bit and got this: plnkr.co/edit/4gKaghePnTMh4NgfQcxC?p=preview
Anyway thanks for answer, Your code helped me getting started
|

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.