We have dynamic templates. Inside ng-repeat
I am using ng-bind-html
which calls a method that returns HTML, but the expressions in that HTML were not rendering. Any idea why?
我们有动态模板。在ng-repeat中我使用的是ng-bind-html,它调用一个返回HTML的方法,但该HTML中的表达式没有呈现。知道为什么吗?
<div ng-bind-html="vm.getSimpleLayoutHtml(item)" class="ng-binding ng-scope">
<div class="col-xs-4" ng-if="item.Account.Name">{{ item.Account.Name }}</div>
</div>
Here is the controller:
这是控制器:
function TestController($scope, resource,$sce)
{
var vm= this;
vm.getSimpleLayoutHtml = function (item) {
var result = resource.getLayout(item.attributes.type, "Simple");
return $sce.trustAsHtml(result.Html);
};
};
1 个解决方案
#1
Give a try to ng-HtmlCompiler @https://github.com/rroxysam/ng-htmlCompiler
试试ng-HtmlCompiler @https://github.com/rroxysam/ng-htmlCompiler
#1
Give a try to ng-HtmlCompiler @https://github.com/rroxysam/ng-htmlCompiler
试试ng-HtmlCompiler @https://github.com/rroxysam/ng-htmlCompiler