Angularjs ui bootstrap - 将 html 放入 popover [英] Angularjs ui bootstrap - put html inside popover

查看:26
本文介绍了Angularjs ui bootstrap - 将 html 放入 popover的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用官方 angular bootstrap 指令.

我想使用它的弹出框.

在文档中它说如果你想在 popover 中插入 html,你应该使用 popover-html,如下所示:

In the documentation it says that if you want to insert html inside the popover you should use popover-html, like bellow :

     <button popover-html="{{getTag()}}" type="button" class="btn btn-default">Dynamic Popover</button>
     <button popover-html="<a>Just fucin show me !</a>" type="button" class="btn btn-default">Click me </button>

但这会引发以下控制台错误:

But this will raise the following console error :

错误:[$parse:syntax] 语法错误:标记<"不是从 [sdfsdfsdf] 开始的表达式 [sdfsdfsdf] 的第 1 列的主要表达式.http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%3C&p1=not%20a%20primary%20expression&p2=1&p3=%3Ca%3Esdfsdfsdf%3C%2Fa%3E&p4=%3Ca%3Esdfsdfsdf%3C%2Fa%3E

Error: [$parse:syntax] Syntax Error: Token '<' not a primary expression at column 1 of the expression [sdfsdfsdf] starting at [sdfsdfsdf]. http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%3C&p1=not%20a%20primary%20expression&p2=1&p3=%3Ca%3Esdfsdfsdf%3C%2Fa%3E&p4=%3Ca%3Esdfsdfsdf%3C%2Fa%3E

您可以看到 plunker

谢谢

推荐答案

只需去掉括号和 $compile 函数:

Just remove the brackets and the $compile function:

HTML:

<button popover-html="getTag()" type="button" class="btn btn-default">Dynamic Popover</button>

JS:

$scope.getTag = function(){
   return '<a>sdfsdfsdf</a>';
}

这篇关于Angularjs ui bootstrap - 将 html 放入 popover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆