Angular:如何在ng-bootstrap下拉菜单中检测切换状态 [英] Angular: How to detect toggle status in ng-bootstrap dropdown

查看:200
本文介绍了Angular:如何在ng-bootstrap下拉菜单中检测切换状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此下拉列表.

如何在模板或ts文件中检测下拉模式的状态?

How can I detect in the template or ts file the status of the dropdown modal?

推荐答案

您需要调用内置函数isOpen()以获取有关特定下拉列表是打开还是关闭的布尔值

You need to call the built-in function isOpen() to get a boolean value of whether a particular dropdown is opened or closed

有关详细信息,请参见 API,方法部分

the detail is given in the API, methods section

相关的 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();
  }
}

这篇关于Angular:如何在ng-bootstrap下拉菜单中检测切换状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆