admin管理员组文章数量:1202361
I am trying to get a Bootstrap 3 popover to display an Angular 2 interpolated template. Is this possible? Here is what I have so far:
$('.ba-header--user-menu').popover({
placement: 'bottom',
toggle: 'popover',
trigger: 'focus',
html: true,
content: '{{user.email}}'
});
Which gives me this:
I am trying to get a Bootstrap 3 popover to display an Angular 2 interpolated template. Is this possible? Here is what I have so far:
$('.ba-header--user-menu').popover({
placement: 'bottom',
toggle: 'popover',
trigger: 'focus',
html: true,
content: '{{user.email}}'
});
Which gives me this:
Share Improve this question edited Jul 12, 2016 at 15:50 Xan 77.5k18 gold badges196 silver badges216 bronze badges asked Mar 7, 2016 at 2:25 Dylan HarnessDylan Harness 7291 gold badge9 silver badges20 bronze badges 6 | Show 1 more comment3 Answers
Reset to default 12JQuery and Angular don't play very well together. Install ng2-popover:
npm i ng2-popover
and use it like this:
<span popover="content to be shown in the popover">
element on which this popover is applied.
</span>
You can also try a library I published ng2-pop-over (not to be confused with ng2-popover mentioned above). It is compact and you'll have to add your styles but has what it takes to solve your problem without jQuery.
yes this is possible but you cannot call interpoleted symbol into jQuery plugin the way you are doing.
you have to assign your dynamic email directly using this
like this.
ngOnInit(){
$('#abc').popover({
placement: 'bottom',
toggle: 'popover',
title: 'khcksahkdfs'
html: true,
content: this.name
});
}
<a id="abc">Toggle popover</a>
working Demo here
本文标签: javascriptHow to use Bootstrap Popover with Angular2Stack Overflow
版权声明:本文标题:javascript - How to use Bootstrap Popover with Angular2 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738651370a2104889.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
bootstrap.js
and useangular-ui-bootstrap
but if you want to continue you need to initialize jquery plugins in directives to assure element exists when code is run. As for compilinginterpolation
braces that won't happen...get content in directive – charlietfl Commented Mar 7, 2016 at 2:34