动态创建 ng 模板以使用 angular-ui-bootstrap 显示弹出框内容
Dynamically creating ng-templates to show popover content using angular-ui-bootstrap
如果我将模板 id 硬编码为 id="popover00.html,则弹出框有效"但是当从ng-repeat生成相同的id时,它不起作用。它正在服务器上查找文件。
弹出式作品:
<div ng-repeat="(keyT, T) in Tdata track by $index">
<div ng-repeat="(keyS,S) in Sdata track by $index" popover-trigger="mouseenter" uib-popover-template={{"'popover"+keyT+keyS+".html'"}} >
<script type="text/ng-template" id="popover00.html">
<div>
This is an HTML <b>template</b><br>
</div>
</script>
</div>
</div>
弹出框不起作用:
<div ng-repeat="(keyT, T) in Tdata track by $index">
<div ng-repeat="(keyS,S) in Sdata track by $index" popover-trigger="mouseenter" uib-popover-template={{"'popover"+keyT+keyS+".html'"}} >
<script type="text/ng-template" id={{"popover"+keyT+keyS+".html"}}>
<div>
This is an HTML <b>template</b><br>
</div>
</script>
</div>
</div>
<script type="text/ng-template" id="templateUrl.html"></script>
提供了一种声明性方法,用于将预加载的 html 内容插入 $templateCache
键等于id
属性值。这是script
指令的祸害:
var scriptDirective = ['$templateCache', function($templateCache) {
return {
restrict: 'E',
terminal: true,
compile: function(element, attr) {
if (attr.type == 'text/ng-template') {
var templateUrl = attr.id,
text = element[0].text;
$templateCache.put(templateUrl, text);
}
}
};
}];
如上所示,attr.id
值是在编译时使用的。在第二个示例中,此值将等于字符串文字'{{"popover"+keyT+keyS+".html"}}'
。这就是你的第二个示例不起作用的原因。
相关文章:
- Angular UI-GRID未在页面上显示网格
- angular ui boostrap日期选择器显示年份第一
- 使用Angular.ui Datepicker没有显示日期
- 如何从$http请求延续中获得显示在angular ui.grid中的数据
- Angular-UI引导日期选择器未在引导模式上显示
- 动态创建 ng 模板以使用 angular-ui-bootstrap 显示弹出框内容
- Angular UI路由器未显示视图
- Angular UI Bootstrap 0.8.0手风琴在IE8中未显示所选值
- Angular UI提前打印结果未显示在下拉列表中
- 以前的值不会显示在Angular UI Select上
- Angular ui网格通过程序设置过滤字段并刷新.值未显示
- 如何在angular ui网格中显示json到ui网格的数据
- Angular UI引导-在typeahead上显示下拉菜单-无结果
- Angular ui-bootstrap的progressbar带Angular -timer不显示值
- 如何使用angular UI引导在弹出窗口上显示HTML
- 用Angular UI路由器高亮显示活动的嵌套状态
- Angular UI在列中显示网格数组
- 无法在Angular UI-Grid中显示安全的html
- Angular UI bootstrap typeahead ng-model在清空文件时显示为null
- Angular ui -路由器嵌套视图不显示页面