I am wondering whether it is possible to write html inside an angularjs bootstrap tabset tab heading. I am trying to add a svg inside the title. I have created a quick snippet in plunker to try and demonstrate the issue I am having.
<tabset>
<tab heading="<span>hello</span><em>1</em>">One</tab>
<tab heading="Two">Two</tab>
<tab heading="Three">Three</tab>
</tabset>
http://plnkr.co/edit/qFsFGDNUIJj9nIF51ApU
any ideas?
thanks
[edit] Taylor Buchanan's answer is the correct answer!
Looking at the template used by the tabs directive, the headings content will be escaped: https://github.com/angular-ui/bootstrap/blob/192768e109b5c4a50c7dcd320e09d05fedd4298a/template/tabs/tab.html#L2
So it is not possible to use html in your headings.
You can create a work-around by re-defining the tab template like so:
You will also need to nclude angular-sanitize.js to safely bind html contents.
Working Demo here: http://plnkr.co/edit/ep5f1GY12vSixT4xtxFy?p=preview
Since 2016
The accepted answer is ok for the ui-bootstrap prior
version 0.14.0
, since version0.14.0
(2015.10.09) tabs useuib-
prefix.See changelog
So you have to replace all tags with
uib-
prefixYou can give your TAB tag an id and then use jQuery to augment the html.
...tab id="myid"....
and then jQuery("#myid").html("New Html")
Angular Bootstrap v0.14+
Angular Bootstrap v0.14 introduced new prefixes for most previously provided controls. The original answer below still applies, but you must use the new tag names
uib-tabset
,uib-tab
, anduib-tab-heading
.Angular Bootstrap < v0.14
You should be using the
tab-heading
element within thetab
element if you want HTML within the heading (as shown in the example in the docs):Updated plunker here.