Angularjs display field as html -


i have a field contains html. when display using {{field}} html not rendered. how display field rendered html? customform.description contains html:

<h4>work requests</h4> <div ng-repeat="customforms in customformgroups" class="row"> <div ng-repeat="customform in customforms" class="col-sm-4">     <strong>{{customform.name}}</strong>     <p>{{customform.description}}</p>     <div class="form-group">         <a class="btn btn-primary" href="javascript:void(0);" ng-click="selectservice(customform)">select</a>     </div> </div> </div> 

use $sce service display html. create function in controller return trusted html:

$scope.displaysafehtml = function(html){   return $sce.trustashtml(html); } 

then use ng-bind-html function:

<p ng-bind-html="displaysafehtml(customform.description)"></p> 

demo

see also: https://docs.angularjs.org/api/ng/service/$sce


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -