简体   繁体   English

如何使用angular ui bootstrap在pop上显示html?

[英]how to show html on pop over using angular ui bootstrap?

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。

<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 我有这个HTML我需要如何在pop上添加这个。我知道在bootrap.js中有方法在popover上添加html。我不想使用我想要使用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 我做了更多尝试,但得到了未定义。可能我错了我只是在做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>

根据文档Angular-ui ,你应该将uib-popover定义为uib-popover而不仅仅是popover ,如果你想将html绑定到uib-popover-html="<div> hello </div>"你可以使用uib-popover-html="<div> hello </div>"或模板绑定uib-popover-template="<<teamplateNameHere>>"

Use AngularUI Bootstrap directive tooltip-html-unsafe 使用AngularUI Bootstrap指令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 演示和代码在这里Plnkr tooltip-html-unsafe

In your options, add a templateUrl. 在您的选项中,添加templateUrl。

For example: 例如:

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

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

tooltip-html-unsafe With Image and Style Tag tooltip-html-unsafe带图像和样式标签

<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>

tooltip-html-unsafe你可以放任何东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM