NgbDropdown autoClose "outside" is not working

Viewed 8595

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.

2 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"
Related