简体   繁体   English

md-next-button 不适用于有角材料

[英]md-next-button not working with angular material

I'm new in angular Material, I want to customize the tabs where I overdid the css of md-tabs like bellow:我是 angular Material 的新手,我想自定义选项卡,其中我过度使用了md-tabs的 css,如下所示:

.md-tabs.md-default-theme .md-tab, md-tabs .md-tab {
  background-color : white !important;
  margin-right:1em;
} 

and my code html is:我的代码 html 是:

<md-content> 
  <md-tabs md-dynamic-height="" md-border-bottom="" style='border-radius: 3px 3px 0 0; !important'>
    <md-tab ng-repeat="itemTab in vm.tabs" label="{{itemTab.label}}" ng-if="vm.showedTabs.indexOf(itemTab.id) > -1">
      <div ng-include="'main.html'"></div><!--ici on insert nos pages de workflow-->
    </md-tab>
  </md-tabs>
</md-content>
<md-button class="md-raised md-primary" ng-click="vm.addNewTabs()">Add new tabs</md-button>

the function named vm.addNewTabs() is used to add new tabs dynamically and it's work fine.名为vm.addNewTabs()的函数用于动态添加新选项卡,并且工作正常。 The problem when I override the css class, the md-next-button doesn't work, it appear but does not working and if I remove margin-right:1em;当我覆盖 css 类时的问题, md-next-button不起作用,它出现但不起作用,如果我删除margin-right:1em; all it work fine.一切正常。

Any one has a idea why this appear?任何人都知道为什么会出现这种情况?

The md-next-button calls the canPageForward function inside of Angular Material to determine if the button should be enabled. md-next-button 调用 Angular Material 内部的 canPageForward 函数来确定是否应该启用该按钮。 This function looks like this:这个函数看起来像这样:

function canPageForward () {
    var lastTab = elements.tabs[ elements.tabs.length - 1 ];
    return lastTab && lastTab.offsetLeft + lastTab.offsetWidth > elements.canvas.clientWidth +
        ctrl.offsetLeft;
  }

Apparently your custom CSS isn't taken into account when calculating the sizes and this function is returning false, therefore disabling the button.显然,在计算尺寸时没有考虑您的自定义 CSS,并且此函数返回 false,因此禁用了按钮。

我使用下一个 scss 修复

md-tabs-canvas { md-pagination-wrapper, md-tabs-dummy-wrapper { white-space: nowrap; md-tab-item, md-dummy-tab { float: none; display: inline-block; } } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM