2016-11-04 84 views
2

我想添加一個按鈕,該按鈕只是一個按鈕,沒有選項卡效果,我將用它來添加更多選項卡。我閱讀和指令文檔,但無法找到如何做到這一點。將按鈕添加到帶有角度材質的md-tab

這裏我的代碼片段:

<div ng-controller="AppCtrl" class="sample tabsdemoDynamicTabs" layout="column" ng-cloak="" ng-app="MyApp"> 
    <md-content class="md-padding"> 
    <md-tabs md-selected="selectedIndex" md-border-bottom="" md-autoselect=""> 
     <md-tab ng-repeat="tab in tabs" ng-disabled="tab.disabled" label="{{tab.title}}"> 
     <div class="demo-tab tab{{$index%4}}" style="padding: 25px; text-align: center;"> 
      <div ng-bind="tab.content"></div> 
      <br> 
      <md-button class="md-primary md-raised" ng-click="removeTab(tab)" ng-disabled="tabs.length <= 1">Remove Tab</md-button> 
     </div> 
     </md-tab> 
     <md-tab > 
     <md-tab-label> 
      <md-icon>add_box</md-icon> 
     </md-tab-label> 
    </md-tab> 
    </md-tabs> 
    </md-content> 

    <form ng-submit="addTab(tTitle,tContent)" layout="column" class="md-padding" style="padding-top: 0;"> 
    <div layout="row" layout-sm="column"> 
     <div flex="" style="position: relative;"> 
     <h2 class="md-subhead" style="position: absolute; bottom: 0; left: 0; margin: 0; font-weight: 500; text-transform: uppercase; line-height: 35px; white-space: nowrap;">Add a new Tab:</h2> 
     </div> 
     <md-input-container> 
     <label for="label">Label</label> 
     <input type="text" id="label" ng-model="tTitle"> 
     </md-input-container> 
     <md-input-container> 
     <label for="content">Content</label> 
     <input type="text" id="content" ng-model="tContent"> 
     </md-input-container> 
     <md-button class="add-tab md-primary md-raised" ng-disabled="!tTitle || !tContent" type="submit" style="margin-right: 0;">Add Tab</md-button> 
    </div> 
    </form> 
</div> 

http://codepen.io/anon/pen/ZBEvVb

回答

2

嘗試使用Navigation Bar,因爲它工作得更好的性能,並直接與路線的作品。您也可以根據需要定義按鈕。這是您需要的示例代碼。

<md-content class="md-padding"> 
<md-nav-bar md-selected-nav-item="currentNavItem" nav-bar-aria-label="navigation links"> 
    <md-nav-item md-nav-click="goto('page1')" name="page1">Page One</md-nav-item> 
    <md-nav-item md-nav-click="goto('page2')" name="page2">Page Two</md-nav-item> 
    <md-nav-item md-nav-click="goto('page3')" name="page3">Page Three</md-nav-item> 
    <span flex></span> 
    <md-button class='md-primary md-raised'>Button</md-button> 
</md-nav-bar> 
<div class="ext-content"> 
    External content for `<span>{{currentNavItem}}</span> 
</div> 
</md-content> 

這裏是working codepen