Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NgbDropdown autoClose "outside" is not working

Tags:

ng-bootstrap

I am using angular4 with ng-bootstrap. I want to close my dropdown on clicking outside the dropdown (rest of document). After reviewing the documentation i identified that autoClose Type: boolean | "outside" | "inside". But when i tried to set it as param config.autoClose = 'outside' then my script start showing this error "Type '"outside"' is not assignable to type 'boolean'."

Any suggestions or help on it.

like image 472
user3373970 Avatar asked Oct 18 '25 21:10

user3373970


1 Answers

In Angular, if you are using ng-Bootstrap. If you want that your dropdown gets closed on click in any part of the screen, then add this line in your code.

[autoClose]="true"

Your code will look like

<div ngbDropdown class="d-inline-block" [autoClose]="true">
     <button class="btn btn-outline-primary" id="dropdownBasic1" ngbDropdownToggle>Option 1 </button>
      <button class="btn btn-outline-primary" id="dropdownBasic1" ngbDropdownToggle>Option 2 </button>
 </div>

If you don't want then put.

[autoClose]="false"
like image 161
Inamur Rahman Avatar answered Oct 22 '25 04:10

Inamur Rahman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!