Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Popover - "data-html='true'" equivalent option not available #520

Closed
callmekatootie opened this issue Jun 14, 2013 · 47 comments
Closed

Popover - "data-html='true'" equivalent option not available #520

callmekatootie opened this issue Jun 14, 2013 · 47 comments
Milestone

Comments

@callmekatootie
Copy link

Hello,

For the popover attribute, I am passing HTML code as follows: <h6>Foo</h6>

However, instead of displaying the "Foo" statement with the h6 tag applied, I get the code as it is, that is the popover content is also <h6>Foo</h6>.

In the Twitter Bootstrap popover, one could specify "data-html='true'" to identify the popover content as being HTML code and that it needs be parsed before display, but I do not see any such option for the Angular UI Bootstrap Popover...

@jhiemer
Copy link

jhiemer commented Jun 14, 2013

@callmekatootie

take a look here: #220

@pkozlowski-opensource
Copy link
Member

@joshdmiller Do you think that adding a html-unsafe version of a popover makes sense? Ir should we really focus on #220?

@joshdmiller
Copy link
Contributor

It's certainly easier to use a popover-html-unsafe version instead of a template, but I've never liked the idea of passing HTML into attributes. But since we did this for the tooltip, it may make sense to do it for the popover as well. If it's something the community wants, I can put out a PR this weekend - it's super trivial to implement. One caveat is that the *-html-unsafe versions, like ng-bind-html-unsafe, do not compile the contents, so directives cannot be used in the provided HTML.

As for #220, I am not exactly sure what's causing the scope bug on the contents but haven't had enough time to really dive into it. I hope to get back into a regular schedule on my open-source commitments this week and this is one of the first things I want to solve.

@NeCkEr
Copy link

NeCkEr commented Jun 20, 2013

+1 to add popover-html-unsafe

@mattymess
Copy link

+1 ^

@dcg
Copy link

dcg commented Jul 3, 2013

+1 to add popover-html-unsafe

@franciscopreller
Copy link

+1 this would be useful

dcg pushed a commit to dcg/angular-ui-bootstrap that referenced this issue Jul 9, 2013
This Feature enables the User to add HTML-Formatted Content to a popover

See: Issue angular-ui#520
@RobbieTheWagner
Copy link

Has this been implemented in angular-ui yet? I would really like to be able to put html in my popovers!

@ajoslin
Copy link
Contributor

ajoslin commented Jul 27, 2013

Move discussion to #641 :-)

@ajoslin ajoslin closed this as completed Jul 27, 2013
@miliu99
Copy link

miliu99 commented Apr 4, 2014

Using template is too complicated. I just want show some text with format, nothing fancy.

@ima-tech
Copy link

ima-tech commented Apr 7, 2014

+1

2 similar comments
@jansoren
Copy link

+1

@lcerveau
Copy link

+1

@cubasuarez
Copy link

+1
"Using template is too complicated. I just want show some text with format, nothing fancy."

@drewrawitz
Copy link

I agree with everyone else. This is something I've really been waiting for. Just being able to use basic HTML in my popovers for better formatting.

@dalpo
Copy link

dalpo commented May 23, 2014

👍

3 similar comments
@morioust
Copy link

+1

@AlexZeitler
Copy link

+1

@avizuber-zz
Copy link

+1

@jollyGreenGiant007
Copy link

This is SO needed.

@NikolajDL
Copy link

+1

6 similar comments
@rolandzwaga
Copy link

+1

@rinterliche
Copy link

+1

@naagii
Copy link

naagii commented Jul 2, 2014

+1

@RatoX
Copy link

RatoX commented Jul 7, 2014

+1

@ofiris
Copy link

ofiris commented Jul 14, 2014

+1

@ephraimm
Copy link

+1

@DominicBoettger
Copy link

+1

8 similar comments
@richardm
Copy link

+1

@doczoidberg
Copy link

+1

@kizdebski
Copy link

+1

@tolgahanaltinok
Copy link

+1

@ghost
Copy link

ghost commented Jul 23, 2014

+1

@mahmoodbazdar
Copy link

+1

@Live2Learn
Copy link

+1

@thisarattr
Copy link

+1

@boillodmanuel
Copy link

I you want to add this functionality to your project, here is a patch.

Add those directives:

angular.module("XXX")
    .directive("popoverHtmlUnsafePopup", function () {
      return {
        restrict: "EA",
        replace: true,
        scope: { title: "@", content: "@", placement: "@", animation: "&", isOpen: "&" },
        templateUrl: "template/popover/popover-html-unsafe-popup.html"
      };
    })

    .directive("popoverHtmlUnsafe", [ "$tooltip", function ($tooltip) {
      return $tooltip("popoverHtmlUnsafe", "popover", "click");
    }]);

And add the template:

<div class="popover {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
  <div class="arrow"></div>

  <div class="popover-inner">
      <h3 class="popover-title" ng-bind="title" ng-show="title"></h3>
      <div class="popover-content" bind-html-unsafe="content"></div>
  </div>
</div>

Usage: <button popover-placement="top" popover-html-unsafe="On the <b>Top!</b>" class="btn btn-default">Top</button>

View in Plunker

Feel free to propose a pull request.

@carloscasal
Copy link

+1 to add popover-html-unsafe

1 similar comment
@fastedy
Copy link

fastedy commented Sep 14, 2014

+1 to add popover-html-unsafe

@fastedy
Copy link

fastedy commented Sep 14, 2014

@boillodmanuel - many thanks for the patch

@sgarbesi
Copy link

+1

@softwaredoug
Copy link

We kept needing an HTML popover, so I've created an alternative popover directive called inspector gadget. Aside from angularized HTML content, also lets you hover inside the popover without hiding it (useful when someone wants to interact with content in the popover or copy/paste). This might solve a lot of the need here.

Just got it to the point where I'm ready to share. Love to get feedback.

@uiur
Copy link

uiur commented Oct 2, 2014

+1

@davidpelayo
Copy link

+1. Thanks @softwaredoug! So useful!

@brianfeister
Copy link

+1. Thanks @boillodmanuel nice and lightweight and concise!

@2013gang
Copy link

@angular-ui angular-ui locked and limited conversation to collaborators Oct 20, 2014
@chrisirhc
Copy link
Contributor

Locking as any additional discussion should go to #220 and feedback should be focused on #1848.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests