Angular ng2引导从组件打开Popover?

Angular ng2引导从组件打开Popover?,angular,ng2-bootstrap,Angular,Ng2 Bootstrap,我在这里查看ng2引导库中的bs popover: . 但是我没有看到任何关于如何从组件代码打开/关闭popover的示例。有人这样做过吗?以下是我当前的视图模板: <template #tipTemplate> <div class="row pop-container" style="position: relative; overflow: hidden;"> <div class="row"> <

我在这里查看ng2引导库中的bs popover: . 但是我没有看到任何关于如何从组件代码打开/关闭popover的示例。有人这样做过吗?以下是我当前的视图模板:

<template #tipTemplate>
    <div class="row pop-container" style="position: relative; overflow: hidden;">
        <div class="row">
            <div class="col-sm-12">
                <button (click)="pop.hide()" class="btn btn-sm btn-danger pull-right">
                    <span class="glyphicon glyphicon-remove-circle"></span>&nbsp;Close
                </button>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <line-chart></line-chart>
                </div>
            </div>
        </div>
    </div>
</template>

<div class="row">
    <div class="col-sm-1 col-sm-offset-1">
        <button type="button" class="btn btn-xs btn-primary" (click)="pop.show()" container="body">
            <i class="fa fa-line-chart" aria-hidden="true"></i>
        </button>
    </div>
    <div class="col-sm-10">
        <span [popover]="tipTemplate"
              #pop="bs-popover"
              popoverTitle="Labs"
              placement="bottom"
              triggers=""
              class="lab-title">
            Troponin
        </span>
    </div>
</div>

它工作得很好,但是我想在我的组件中调用一个函数,然后做一些事情,其中之一就是打开popover,而不是直接打开popover的按钮单击事件。使用此库是否可以执行此操作?

您需要将其添加到组件中。ts

import { Component, OnInit, ViewChild } from '@angular/core';
在组件内部

@ViewChild('childModal') public childModal: ModalDirective;
然后,每当你想打开模态

 this.childModal.show();

上面的代码是模态代码,但是你可以使用samethanks!,我应该意识到同样的模式也适用于popover:。