[英]Is there a way to detect if the selection panel on a md-autocomplete material2+angular2 is being shown?
I am trying to detect if the panel is being shown or not but from the documentations, I can't seem to figure out what to use that will correctly tell me which property would trigger the right event. 我试图检测是否正在显示该面板,但是从文档中,我似乎无法弄清楚该使用什么来正确告诉我哪个属性将触发正确的事件。
If anyone can help, thanks. 如果有人可以帮助,谢谢。
md-autocomplete
has a property called showPanel
. md-autocomplete
具有一个名为showPanel
的属性。 You can return the value of showPanel
using the #
reference of autocomplete. 您可以使用自动完成的#
引用返回showPanel
的值。
Here's an example, for every keyup
event in the input field, I check the value of showPanel
and push it to an array for verifying if it works. 这是一个示例,对于输入字段中的每个keyup
事件,我都会检查showPanel
的值,并将其推入数组以验证其是否有效。
html: 的HTML:
<md-input-container>
<input mdInput placeholder="State"
[mdAutocomplete]="auto"
[formControl]="stateCtrl"
(keyup)="checkPanel(auto.showPanel)">
</md-input-container>
<md-autocomplete #auto="mdAutocomplete">
<md-option *ngFor="let state of filteredStates | async" [value]="state">
{{ state }}
</md-option>
</md-autocomplete>
<p></p>
<div style="margin-top: 300px">
<span>Is panel open at keyup:</span>
<div *ngFor="let x of flags; let i = index">
keyup {{i+1}}: {{x}}
</div>
</div>
ts: ts:
checkPanel(val){
this.flags.push(val);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.