如何使用angular UI引导在弹出窗口上显示HTML
how to show html on pop over using angular ui bootstrap?
我做了一个弹出窗口的演示,当我点击按钮时,它会在右侧显示一个弹出窗口,但现在的问题是我如何在弹出窗口上显示一些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>
我有这个HTML,我需要把它添加到弹出窗口上,我知道在bootstrap。js中有办法在弹出窗口上添加HTML,我不想用它,我想用angular UI bootstrap。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>
我做了更多的尝试,但没有定义。也许我错了,我只是在做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>
使用AngularUI引导指令tooltip-html-unsafe
<span tooltip-html-unsafe="<div>Hi</div><div>Hi Hi Hi</div><div>Hi</div>">
<b>Hover on Me!</b>
</span>
演示和代码在这里Plnkr tooltip-html-unsafe
根据docs Angular-ui,你应该将弹出窗口定义为uib-popover
而不仅仅是popover
,如果你想将html绑定到弹出窗口,你可以使用uib-popover-html="<div> hello </div>"
或模板绑定uib-popover-template="<<teamplateNameHere>>"
在您的选项中添加templateUrl.
例如:templateUrl: 'your/url' + type + 'popup.html'
更多信息:https://github.com/angular-ui/bootstrap/tree/master/src/modal/docs
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你可以在里面放任何东西
相关文章:
- 谷歌地图API-信息窗口显示谷歌位置API信息
- 如何使用 javascript 警报窗口显示验证消息
- 使用模式消息/窗口显示数据库记录
- 单击按钮并将其下载为图像格式时,如何使用引导模式弹出窗口显示D3图表
- 为什么我的html弹出窗口显示我的函数的文本,而不是运行它们
- 如何让角度引导弹出窗口显示字典值
- 当子窗口打开时,父窗口显示为灰色
- 如何检查是否允许弹出窗口显示在客户端的浏览器中
- 同步窗口.显示()
- 简单模式弹出窗口显示每个会话一次
- 谷歌api信息窗口显示在谷歌地图api上的1个标记下
- 单击传单中的标记时,如何防止弹出窗口显示
- 点击警报窗口显示
- 如何使用ajax的Magnific弹出窗口显示测验
- 在弹出窗口打开之前,模式弹出窗口中的Elevate zoom缩放窗口显示在内容后面
- 对溢出的文本进行设置时,角度uib弹出窗口显示在错误的位置
- 你能控制用Javascript创建的窗口显示在哪个显示器上吗
- 在双显示器上复制弹出窗口显示
- 信息窗口显示在同一标记上
- 模式窗口显示得非常简短