ng-bind-html内的表达式无法呈现

时间:2015-05-05 14:08:22

标签: angularjs angular-ui ng-bind-html

我们有动态模板。在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>

这是控制器:

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 个答案:

答案 0 :(得分:0)

Give a try to ng-HtmlCompiler @https://github.com/rroxysam/ng-htmlCompiler