2016-12-16 39 views

回答

1

ng-bind将始终打印模型中的内容。 你可以做以下的事情:

<div> 
    <div ng-bind="model"></div> 
    <div>inner html</div> 
</div> 

要么你可以这样做:

//JS 
app.controller("nameController", function($sce) { 
    model = $sce.trustAsHtml("<div>inner html</div>"); 
}); 

//HTML 
<div ng-bind-html="model"></div> 
+0

非常感谢,这对我的作品。但总是在js代码中使用html将难以维护。 –

+0

'// JS app.controller(“nameController”,function($ sce){ model = $ sce.trustAsHtml(“

inner html
”); }); // HTML
' –