Is it possible to have both dropdown and dropup options on the same page using ng-bootstrap?
I attempted to implement the code provided in the ng-bootstrap documentation, but it only allows for a global configuration of dropdowns. I specifically need to display both dropdown and dropup menus on the same page. My project is based on Angular 8.
import {Component} from '@angular/core';
import {NgbDropdownConfig} from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'ngbd-dropdown-config',
templateUrl: './dropdown-config.html',
providers: [NgbDropdownConfig] // add NgbDropdownConfig to the component providers
})
export class NgbdDropdownConfig {
constructor(config: NgbDropdownConfig) {
// customize default values of dropdowns used by this component tree
config.placement = 'top-left';
config.autoClose = false;
}
}
<div ngbDropdown>
<button class="btn btn-secondary" type="button" id="dropDownMenuButton" ngbDropdownToggle>
Dropup Menu
</button>
<div class="dropdown-menu tx-13" ngbDropdownMenu aria-labelledby="dropDownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
<div class="dropup" ngbDropdown>
<button class="btn btn-secondary" type="button" id="dropupMenuButton" ngbDropdownToggle>
Dropup Menu
</button>
<div class="dropdown-menu tx-13" ngbDropdownMenu aria-labelledby="dropupMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>