0

当某些参数等于“N”时,我需要禁用导航内的元素列表,并在等于“S”时启用它。这是我的代码

<div class="slidebar-nav">
  <nav class="navbar navbar-default" role="navigation">
    <!-- Main Menu -->
    <div class="side-menu-container">
      <ul class="nav navbar-nav">
        <li ng-disabled="trxAbil.I9WSFONI == 'N'" 
            ng-class="{'current' : itemSelected === 'Gestione fondi'}"
            ui-sref="home.pag1.inquiryFondi({innescatoDaMenuLaterale: true})" 
            ng-click="onMenuSelection('Gestione fondi')">
          <a><span class="glyphicon glyphicon-edit"></span> Gestione fondi</a>
        </li>
        <li class="active" 
            ng-class="{'current' : itemSelected === 'Invio fondi'}"
            ui-sref="home.pag2" ng-click="onMenuSelection('Invio fondi')">
          <a><span class="glyphicon glyphicon-send"></span> Invio fondi</a>
        </li>
        <li class="active" 
            ng-class="{'current' : itemSelected === 'Sintesi fondi'}" 
            ui-sref="home.pag3" ng-click="onMenuSelection('Sintesi fondi')">
          <a><span class="glyphicon glyphicon-send"></span> Sintesi fondi</a>
        </li>
      </ul>
    </div>
  </nav>
</div>

我尝试使用,ng-disabled="trxAbil.I9WSFONI == 'N'"但它不起作用。有任何想法吗?先感谢您

4

2 回答 2

2

我假设您在 UI 中使用 Bootstrap(通过观看navbar navbar-default课程)。

您只需要disabled根据您的条件分配类即可禁用菜单中的项目。它将自动阻止单击该项目。

<li ng-class="{'current' : itemSelected === 'Gestione fondi', 'disabled': trxAbil.I9WSFONI == 'N'}" ... > ... </li>

无需分配ng-disabledli元素。

于 2017-07-14T08:23:40.917 回答
1

如果您想显示该项目但使其不可点击并使用 CSS 禁用或您正在使用引导程序,则在标签中添加'disabled' : trxAbil.I9WSFONI == 'N'条件ng-class属性:<li>

CSS:

.disabled {
    pointer-events:none; //This makes it not clickable
    opacity:0.6;         //This grays it out to look disabled
}

HTML:

<li ng-class="{'disabled' : trxAbil.I9WSFONI == 'N', 'current' : itemSelected === 'Gestione fondi'}"   ui-sref="home.pag1.inquiryFondi({innescatoDaMenuLaterale: true})" ng-click="onMenuSelection('Gestione fondi')"><a><span class="glyphicon glyphicon-edit"></span> Gestione fondi</a></li>
于 2017-07-14T08:13:21.113 回答