0

I would like to open dropdown only if condition is fulfilled. How can I do this? Now my code looks like:

<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
     }
 }

1 Answer 1

1

Have you tried to use ng-disabled : (if variable test is true you can't open dropdown)

<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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.