1

I am using textangular directive for angular text editor I have a string in database as:

State of Ticket: #TicketState            
                <br>  <br/>
       Ticket Url: <#LinkTextStart>Click</#LinkTextEnd>
        <br>  <br/>

I want this value to be displayed in text editor

 <text-angular  ng-bind-htm="html" ></text-angular>

when I use ng-bind-html it ignores </#LinkTextEnd> and displays all the remaning string without text editor

and when I use ng-model then it opens empty text editor

my requirement is to show Ticket Url: <#LinkTextStart>Click</#LinkTextEnd> inside text editor

4
  • what is text-angular? is it a component? Commented Jun 30, 2017 at 5:50
  • You want to escape the <br> tags and convert them into newlines, but not the <#LinkTextStart>Click</#LinkTextEnd> part is it ? Commented Jun 30, 2017 at 6:25
  • text-angular is a directive for text editor @Aravind Commented Jun 30, 2017 at 7:27
  • yes you are absolutely right @PrabodhM Commented Jun 30, 2017 at 7:28

1 Answer 1

2

You need to set the html as trusted for security reasons. You can use a filter.

app.filter('to_trusted', ['$sce', function toTrustedHtml($sce) {
    return function(text) {
        return $sce.trustAsHtml(text);
    };
}]);

and use it like

<text-angular  ng-bind-html="html | to_trusted" ></text-angular>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.