15

I make demo of pop over like this .It show a pop over on right side when I click the button .But now problem is that how I will show some html on pop over .

<html ng-app="plunker">

  <head>
     <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script>
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
  </head>

  <body>
    <button popover-placement="right" popover="On the Right!" class="btn btn-default">Right</button>
  </body>
<script>
angular.module('plunker', ['ui.bootstrap']);

</script>  

</html>

I have this HTML I need to how on add this on pop over .I know there is way in bootrap.js to add html on popover .I don't want to use that I want to use angular UI bootrap.js

<div ng-controller="axcont">
<ul class="list-group">
  <li class="list-group-item" ng-click="add()">add row</li>
  <li class="list-group-item " ng-click="deleteRow($index)">Deleterow</li>

</ul>
</div>

I did more try on that like that but getting undefined.May be I am wrong I just doing RND

<html ng-app="plunker">

  <head>
     <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script>
    <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
    <script src="example.js"></script>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
  </head>

  <body>
    <button pop-over title="Mode of transport" content-url="pop.html" class="btn btn-default">Right</button>
  </body>
<script>
var a=angular.module('plunker', ['ui.bootstrap']);
a.directive('popOver', function ($compile, $http, $templateCache) {
  return {
    restrict: 'A',
    scope: true,
    link: function popOverPostLink(scope, elem, attrs) {
      $http.get(attrs.contentUrl, {cache: $templateCache}).success(
        function (tmpl) {
          var options = {
            content: $compile(tmpl)(scope),
            placement: 'bottom',
            html: true,
            trigger:'click',
            title: attrs.title
          };
          elem.popover(options);
          scope.hidePopover = function () {
            elem.popover('hide');
          }
        }
      );
    }
  };
});

</script>  

</html>
6
  • In your code above, you are using the bootstrap.js with elem.popover. Commented Aug 9, 2014 at 6:44
  • yes..but I don't want to use bootstrap.js.I want to use only angular UI bootstrap to make pop over.some developer said it better to uses Angular UI botrap because it gives all callback event Commented Aug 9, 2014 at 6:45
  • @runTarm do you have any idea make pop over without bootrap.js Commented Aug 9, 2014 at 6:54
  • This is not support out of the box by Angular UI Bootstrap yet, see a long discussion here. You have to create your own custom directive or consider using another project angular-strap Commented Aug 9, 2014 at 7:09
  • @runTarm thanks for giving information can you using my html and load it on button click if you have idea of custom directive Commented Aug 9, 2014 at 7:13

5 Answers 5

1

Use AngularUI Bootstrap directive tooltip-html-unsafe

<span tooltip-html-unsafe="<div>Hi</div><div>Hi Hi Hi</div><div>Hi</div>">   
   <b>Hover on Me!</b>
</span>

Demo and code is in here Plnkr tooltip-html-unsafe

Sign up to request clarification or add additional context in comments.

9 Comments

thanks for giving answer .but there is issue in that ..I need that on click ..secondly why you are using this $scope.htmlTooltip = '<div><span>Hi I am a tooltip</span></div>';
I forgot to remove the $scope.htmlTooltip = '<div><span>Hi I am a tooltip</span></div>'; I fixed in the plnkr.
Got your update. You want tooltip on click not on hover ? Is that correct ?
yes thank if you take my html it is more better (having ul and li)
why I am saying to take my html because I need to take click event of li
|
1

According to the docs Angular-ui, you should be defining the popover as uib-popover instead of just popover, and if you would like to bind html to the popover you would either use uib-popover-html="<div> hello </div>" or template binding uib-popover-template="<<teamplateNameHere>>"

Comments

0

In your options, add a templateUrl.

For example:

templateUrl: 'your/url' + type + 'popup.html'

More info: https://github.com/angular-ui/bootstrap/tree/master/src/modal/docs

Comments

0

tooltip-html-unsafe With Image and Style Tag

<span tooltip-html-unsafe="<img src='https://upload.wikimedia.org/wikipedia/commons/0/00/Lubuntu-icon.png' style='width:24px;'>
      <div style='font-size:24px;'>Tooltip With Image</div>">   
           <b>Hover on Me!</b>
</span>

Comments

0

tooltip-html-unsafeyou can put anything in it

1 Comment

This does not add anything that the other existing answers do not already cover. It would be better to upvote or comment on the other answers if you do not have anything new to add.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.