angularjs - 使 angularJS ui 路由器与 Angular Material 设计 TABS 一起工作

标签 angularjs angular-ui-router material-design

TabControl 在应用程序启动时可见,但...

当我单击选项卡时,没有内容可见

我怎么了?

我使用最新的 angularJS Material 设计 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>

最佳答案

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



已在 github 上发布了一种解决方法,位于 previous known md-tab issue :

有一个 plunker使用解决方法(它似乎在没有 View 的情况下工作):
  $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'
      });

关于angularjs - 使 angularJS ui 路由器与 Angular Material 设计 TABS 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30415698/

相关文章:

javascript - 解决任何状态下的 UI-Router

javascript - NG-STYLE 在 angularjs 中不起作用

javascript - 我可以在 mdDialog 中添加变量或函数吗?

javascript - 无法存储使用 Angular.js UI Router 构建的多步骤表单的数据

javascript - AngularJS UI-Router 使用 DOT 处理 url

html - 从 Material 设计中的 .mdl-layout__drawer-button 中删除外边框线?

material-design - 水平滚动卡就像 Android 中 Lollipop 的最新应用程序一样?

javascript - Material Design Web 1.0 quickstart 问题与脚本模块和 onclick 处理程序

angularjs - Angular - 在服务 $http 调用后设置 Controller 变量

javascript - 如何在AngularJS语法ES6中的两个组件之间传递数据?