Render data as html
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
Column: IsStatic = True , TaggedValue DataIsHtml=True | Column: IsStatic = True , TaggedValue DataIsHtml=True | ||
==== Implementation ==== | |||
In Razor the implementation use | In Razor the implementation use | ||
Html.Raw(<normal bind>) | Html.Raw(<normal bind>) | ||
Line 14: | Line 15: | ||
return function(val) { return $sce.trustAsHtml(val); }; | return function(val) { return $sce.trustAsHtml(val); }; | ||
}]); | }]); | ||
We then bind like this: | |||
<nowiki><div ng-bind-html="<normal identifier> | rawHtml"></div></nowiki> |
Revision as of 08:46, 30 September 2018
This page was created by Hans.karlsen on 2018-09-30. Last edited by Stephanie on 2025-02-24.
If your data contains html markup and you want the browser to render the html go like this:
Column: IsStatic = True , TaggedValue DataIsHtml=True
Implementation
In Razor the implementation use
Html.Raw(<normal bind>)
In AngularJS it is more complex due to security concerns:
Must inject service $sce. $sce is a service that provides Strict Contextual Escaping services to AngularJS.
We must also use a filter to say that data is trusted as html:
.filter('rawHtml', ['$sce', function($sce) { return function(val) { return $sce.trustAsHtml(val); }; }]);
We then bind like this:
<div ng-bind-html="<normal identifier> | rawHtml"></div>