【问题标题】:Angular-ui bootstrap don't work correctly with templatesAngular-ui 引导程序无法与模板一起正常工作
【发布时间】:2014-09-10 15:51:29
【问题描述】:

我使用 angular-ui-bootstrap 弹出框。我手动更改了弹出框模板以支持其中的 html。我将 ng-bind 更改为 ng-bind-html:

<div class=\"popover-content\" ng-bind-html=\"content\"></div>

我将这样的模板传递给popover 属性:

<span ng-click="scopeFunction()">{{somethingFromScope}}</span>

所以{{somethingFromScope}} 可以解析并且可以工作,但是ng-click 函数不起作用。 ng-showng-if(看起来像任何 ng- 指令)也不能正常工作。

这是什么原因?我怎样才能让它工作? 谢谢

【问题讨论】:

    标签: javascript html angularjs angular-ui-bootstrap


    【解决方案1】:

    仅仅改变模板是不够的

    像这样更新模块依赖:

      angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip', 'ui.bootstrap.bindHtml'])
    

    并更改模板

      <div class="popover-content" bind-html-unsafe="content"></div>
    

    从 2014 年 5 月 1 日起与 angular.ui.bootstrap v0.11.0 一起使用

    【讨论】:

    • @n8m 再次考虑您的问题后,唯一真正的选择是从 ui.bootstrap 复制模态指令并对其应用弹出框样式。甚至复制弹出框模板并将该布局包含在您的父指令中,有条件地显示和隐藏它,您也可以使用 ui.bootstrap 中的 $position 服务来正确定位您自己的弹出框。
    • 但是为什么双括号中的表达式求值,但是 ng-directives 不起作用?
    【解决方案2】:

    经过大量研究,我找到了解决方案:

    如果您需要带有模板的弹出框 - 使用 AngularStrap 弹出框 ;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      相关资源
      最近更新 更多