【发布时间】:2018-10-05 10:22:16
【问题描述】:
我想在一个链接上使用ngx-bootstrap popover,我点击那个链接,底部会显示一个弹出框。
在 ngx-bootstrap 网站中:我发现我们可以使用带有自定义模板的 Button,以便通过这种方式在弹出框内显示我们想要的任何内容:
<ng-template #popTemplate>Just another: {{content}}</ng-template>
<button type="button" class="btn btn-warning"
[popover]="popTemplate" popoverTitle="Template ref content inside">
TemplateRef binding
</button>
我有兴趣使用这个ng-template 示例在我的案例中显示用户信息,我们点击该用户的链接图像。
因此,例如以这种方式尝试时,我无法触发此弹出框:
<a href="#" role="button" (click)="popTemplate.show()" placement="bottom">
<span>
<img src="urlPhoto"></img>
</span>
</a>
<ng-template #popTemplate>Here we go
name: {{user.name}}
</ng-template>
我正在寻找类似于我们在这个问题中所做的事情:
Bootstrap Popover - how add link in text popover?
但使用 ngx-bootstrap 弹出框。
有人知道正确的方法吗?
目前我在控制台中有这个错误:
【问题讨论】:
-
您是否在控制台中遇到任何错误?
-
您是否尝试过在您的
a元素上使用[popover]="popTemplate"? -
我试过
popover绑定,它可以工作
标签: angular hyperlink ngx-bootstrap ngx-bootstrap-popover