问题
I am working with this dropdowns.
How can I detect in the template or ts file the status of the dropdown modal?
回答1:
You need to call the built-in function isOpen() to get a boolean value of whether a particular dropdown is opened or closed
the detail is given in the API, methods section
relevant TS:
import {Component, ViewChild} from '@angular/core';
@Component({
selector: 'ngbd-dropdown-basic',
templateUrl: './dropdown-basic.html'
})
export class NgbdDropdownBasic {
@ViewChild(NgbDropdown)
private dropdown: NgbDropdown;
checkDropDown() {
return this.dropdown.isOpen();
}
}
来源:https://stackoverflow.com/questions/56473532/angular-how-to-detect-toggle-status-in-ng-bootstrap-dropdown