【发布时间】:2019-05-04 02:58:04
【问题描述】:
目前我有这样的智能弹出框设置,带有一个附加按钮并在点击时显示。这是放在它自己的组件中的:
<popover-content #myPopover id="myPopover"
placement="bottom" [animation]="true" [closeOnClickOutside]="false" >
// Some content here
</popover-content>
<input type='button' #selectMyPopover [popover]="myPopover" class='btn'
popoverPlacement="bottom" [popoverOnHover]="false"
[popoverCloseOnMouseOutside]="false" [value]='myButton'>
然后当我想使用它时,我将它包含在组件标签中,如下所示:
<app-my-popover></app-my-popover>
这很好,但我发现的所有示例都需要使用这样的附加按钮:
<input type='button'[popover]="myPopover"...
我正在尝试根据条件显示弹出框,而不必单击该按钮。例如:
myMethod()
{
if(true)
{
this.myPopover.open();
}
}
是否可以自己以类似的方式从打字稿中打开而不是使用按钮?
【问题讨论】:
-
获取
ViewChild,然后就可以调用open方法了。
标签: angular typescript