Could anyone please help me figure out why ng-bind-html doesn't work with CaseComponents.CommentBody?

<table class="table table-hover">
            <th>Created By</th>
        <tr ng-repeat="ticketComment in modalObject.Case.CaseComments">
            <td >
                <span style="label-value" ng-bind="ticketComment.CreatedBy.Name"></span>
                <p style="label-value" ng-bind="ticketComment.CreatedDate | date:'medium'"></p>
            <td style="max-width: 400px; word-wrap: break-word;"><div ng-bind-html="trustedHtml(ticketComment.CommentBody)"></div></td>

In my angular controller, I have

$scope.trustedHtml = function (plainText) {
        testing = "<h1><div style='color:red'> Tranzact Tickets</div> <h1> <br />"
        return $sce.trustAsHtml(plainText);

Everything worked perfectly except the ng-bind-html doesn't seem to insert the ticketComment.CommentBody as HTML which has elements like <br /> but it outputs as string "Hello <br /> We will contact you as soon as possible <br /> IT".

I even tried to create a variable called testing and the function trustedHtml() did return testing as HTML.

I am thinking maybe CommentBody is not string or ng-bind-html just doesn't work well with ng-repeat?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.