是否可以在Angular材料设计中的选项卡中包含选项卡

时间:2015-10-22 10:32:37

标签: angularjs angular-material

<md-tabs class="md-primary">
  <md-tab label="1">
    <md-tab-label>Step 1)</md-tab-label>
    <md-tab-body>
      <md-tabs>
        <md-tab label="1sub">
          <md-tab-label>Tab within tab</md-tab-label>
          <md-tab-body>
            Some tab data
          </md-tab-body>
        </md-tab>
      </md-tabs>
    </md-tab-body>
  </md-tab>
</md-tabs>

是否可以在标签中创建标签?上面最简单的例子(原谅嵌套)并没有真正起作用,&#34;子标签&#34;不能正确渲染。标签不起作用,内容不会显示。

2 个答案:

答案 0 :(得分:4)

简短回答 - 是的。

我有同样的问题,并没有任何问题让这个工作:

&#13;
&#13;
<html lang="en" >
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Angular Material style sheet -->
  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
</head>
<body ng-app="BlankApp" ng-cloak>
  <div>
    <h1>Tab Demo</h1>
    <md-content class="md-padding">
      <md-tabs md-dynamic-height md-stretch-tabs>
        <md-tab label="Top Level 1">
          <h3>Top Level 1 Content</h3>
          <md-tabs md-dynamic-height md-stretch-tabs style="padding-left: 5em;">
            <md-tab label="Sub-Level 1">
              <h4>Top1 Sub1 Content</h4>
            </md-tab>
            <md-tab label="Sub-Level 2">
              <h4>Top1 Sub2 Content</h4>
            </md-tab>
            <md-tab label="Sub-Level 3">
              <h4>Top1 Sub3 Content</h4>
            </md-tab>
          </md-tabs>
        </md-tab>
        <md-tab label="Top Level 2">
          <h3>Top Level 2 Content</h3>
        </md-tab>
        <md-tab label="Top Level 3">
          <h3>Top Level 3 Content</h3>
          <md-tabs md-dynamic-height md-stretch-tabs style="padding-left: 5em;">
            <md-tab label="Sub-Level 1">
              <h4>Top3 Sub1 Content</h4>
            </md-tab>
            <md-tab label="Sub-Level 2">
              <h4>Top3 Sub2 Content</h4>
            </md-tab>
            <md-tab label="Sub-Level 3">
              <h4>Top3 Sub3 Content</h4>
            </md-tab>
          </md-tabs>
        </md-tab>
      </md-tabs>
    </md-content>
  </div>
  
  <!-- Angular Material requires Angular.js Libraries -->
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>

  <!-- Angular Material Library -->
  <script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
  
  <!-- Your application bootstrap  -->
  <script type="text/javascript">    
    /**
     * You must include the dependency on 'ngMaterial' 
     */
    angular.module('BlankApp', ['ngMaterial']);
  </script>
  
</body>
</html>

<!--
Copyright 2016 Google Inc. All Rights Reserved. 
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at http://material.angularjs.org/license.
-->
&#13;
&#13;
&#13;

这应该让你去。

干杯, 丹

答案 1 :(得分:0)

请注意,Material Design中明确不支持嵌套选项卡。请参阅Material Design - Tabs component的最后一个示例或此github讨论:setting class on nested tabs

你应该考虑另一种方法!