Angular: How to detect toggle status in ng-bootstrap dropdown

你离开我真会死。 提交于 2019-12-24 19:07:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!