2016-12-16 52 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
' –