【问题标题】:How can I open dropdown manually, under condition in angularjs?如何在 angularjs 的条件下手动打开下拉菜单?
【发布时间】:2019-07-18 13:22:59
【问题描述】:

我只想在满足条件时打开下拉菜单。我怎样才能做到这一点?现在我的代码看起来像:

<div class="btn-group" uib-dropdown>
  <button class="btn btn-secondary" uib-dropdown-toggle ng-click="vm.openDropdown()">
  open
</button>
  <div class="dropdown-menu dropdown-menu-right" uib-dropdown-menu>
    <a class="dropdown-item d-inline-flex" ng-repeat="test in vm.tests">{{test}}</a>
  </div>
</div>

vm.openDropdown = openDropdown
vm.tests = [1, 2, 3, 4]

function openDropdown () {
    if (vm.test == true) {
////and here I need have condition if something is true, I do not want to open dropdown
     }
 }

【问题讨论】:

    标签: angularjs angular-ui-bootstrap dropdown


    【解决方案1】:

    您是否尝试过使用ng-disabled :(如果变量测试为真则无法打开下拉菜单)

    <div class="btn-group" uib-dropdown>
        <button class="btn btn-secondary" uib-dropdown-toggle ng-disabled="vm.test">open
        </button>
        <div class="dropdown-menu dropdown-menu-right" uib-dropdown-menu>
           <a class="dropdown-item d-inline-flex" ng-repeat="test in vm.tests">{{test}}</a>
        </div>
    </div>
    

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 2021-09-15
      • 2020-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      相关资源
      最近更新 更多