AngularJS的ng-bind-html没有按需要工作,尽管使用了$ scene . trustashml
AngularJS ng-bind-html not working as needed in spite the use of $sce.trustAsHtml
我有一个页面,其内容将根据从数据库检索到的数据来定义。
我通过设置"div"使用ng-bind-html,并使用$ scene . trustashhtml部署html内容(在页面的控制器中构建)。
这只在第一次起作用。如果内容需要重新构建(例如,作为用户操作的结果),什么也不会发生。
经过一番研究,我发现一些帖子似乎需要调用编译进程,但我不确定我理解这是什么意思以及如何做到这一点。
我的问题是:
-
我的理解是否正确(关于编译)?
-
如果是,该怎么做?
-
这个编译也涉及到onclick指令不工作的元素如上所述构建的事实?(注意:如果我手动部署与JavaScript生成的相同的HTML代码,则onclick指令可以完美地工作)。
<table class="table table-hover table-condensed" ng-bind-html="This_Table_Results" style="width:100%;border: 1px solid gray;padding:5px 5px 5px 5px"> </table>
和控制器部分:
$scope.This_Table_Results = $sce.trustAsHtml (l_Data_Table) ;
你可能想看看这里被接受的答案:
$ scene . trustashhtml中的渲染指令
"为了动态添加HTML,你应该查看$compile服务(和/或指令)。[…]"
相关文章:
- 尽管有$ scene . trustashhtml (), Angularjs还是不信任自定义指令中的HTML
- AngularJS的ng-bind-html没有按需要工作,尽管使用了$ scene . trustashml
- 为什么angular没有从$ scene . trustashhtml插入的输入中获取ng-models的值?
- Eval'd behind the scene?
- 在使用$sce之后.trustashml, ng-click不工作
- Canvas (Three.js) scene with Angular
- 为什么是我的$sce.将trustashml内容呈现为纯文本
- 使用IME与Scene"集成输入字段在三星智能电视