Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  192] [ 7]  / answers: 1 / hits: 28049  / 8 Years ago, thu, may 26, 2016, 12:00:00

How to display Html from value? Like @Html.Raw() in ASP.NET. Because in current example i get only text with tags.



JS:



var app = angular.module('Demo', []);
app.controller('TestCtrl', function ($scope) {
$scope.value = '<p>List</p><ul><li>Test 1</li><li>Test 2</li><li>Test 3</li><li>Test 4</li></ul>'
});


view:



<div ng-controller=TestCtrl>
{{value}}
</div>

More From » html

 Answers
5

use



<div ng-bind-html=value></div>


instead of



{{value}}


you have to use $sce provider to process your code to get a safe context.



$scope.value= $sce.trustAsHtml(yourHtmlCode);

[#62007] Wednesday, May 25, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
miranda

Total Points: 655
Total Questions: 110
Total Answers: 121

Location: Netherlands
Member since Thu, Jul 1, 2021
3 Years ago
;