使用open openPanel()方法打开matAutocomplete [英] Open matAutocomplete with open openPanel() method

查看:83
本文介绍了使用open openPanel()方法打开matAutocomplete的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Angular Material的 matAutocomplete 组件,并且根据文档,有一种方法可以打开/关闭具有openPanel()/closePanel()方法的自动完成面板.关于如何将其集成到已经正常工作的示例中的任何建议?

I'm working with Angular Material's matAutocomplete component, and according to the docs, there is a method which can open/close an autocomplete panel with a openPanel()/closePanel() method. Any suggestion to how can I integrate it into already working example?

这是我对实时示例.

推荐答案

在模板中

<button (click)='openPanel($event)'>Open</button>

<input #inputAutoComplete>

以ts

@ViewChild(MatAutocompleteTrigger, {read: MatAutocompleteTrigger}) inputAutoComplete: MatAutocompleteTrigger;


openPanel(evt): void {
  evt.stopPropagation();
  this.inputAutoComplete.openPanel();
}

这篇关于使用open openPanel()方法打开matAutocomplete的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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