Angularjs ui bootstrap - put html inside popover

2019-08-11 06:50发布

I'm using official angular bootstrap directives .

I want to use of of it's popovers .

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 :

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

You can see the plunker

Thanks

1条回答
萌系小妹纸
2楼-- · 2019-08-11 07:34

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>';
}
查看更多
登录 后发表回答