ngbPopover will not close and will open on load

拜拜、爱过 提交于 2020-01-06 05:24:06

问题


I want to show the popover once the page load or without trigerring the button and will never close I'm using ngbPopover in Angular.

<button placement="left" (click)="openQuestionnaire()" [ngbPopover]="popContent" >0/4</button>

using the reference here : https://ng-bootstrap.github.io/#/components/popover/examples


回答1:


You have to add this property to your button:

[autoClose]="false"

Then your button would look like this:

<button placement="left" 
        (click)="openQuestionnaire()" 
        [ngbPopover]="popContent" 
        [autoClose]="false" >0/4</button>

From the link you shared i found this:

<button type="button" class="btn btn-outline-secondary mr-2" 
        ngbPopover="What a great tip!" 
        [autoClose]="false" 
        triggers="manual" 
        #p="ngbPopover" 
        (click)="p.open()" 
         popoverTitle="Pop title">
             Click me to open a popover
</button>

As per your comment, you can trigger it when your component is shown in the page:

<button placement="left" 
        #pop="ngbPopover"
        (click)="openQuestionnaire()" 
        [ngbPopover]="popContent" 
        [autoClose]="false" >0/4</button>

in your component class:

ngOnInit(){
    if(!pop.isOpen()){
        pop.open();
    }
}


来源:https://stackoverflow.com/questions/53314880/ngbpopover-will-not-close-and-will-open-on-load

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