0

I have made a custom filter it outputs text. However, it puts html as is too. I want it to put html as html not escape it.

If i return html text it get escaped. So is there a way to overcome this.

I have tried $sce.trustAsHtml.

My angular version is 1.2.29

Linked answer requires a different approach, the approach that could work doesn't work for some reasons as also noted by others.

4
  • 1
    Possible duplicate of How to create angularjs filter which outputs HTML Commented Jul 5, 2016 at 21:56
  • i have already left a comment at one of the answers there that this doesn't work Commented Jul 5, 2016 at 21:56
  • @MuhammadUmer Have you included 'ngSanitize' in the dependencies list of your app module? Commented Jul 5, 2016 at 21:58
  • 1
    Show us the code. We don't know what you are doing or why it isn't working Commented Jul 5, 2016 at 22:02

1 Answer 1

0

You need to update your angular if possible. You can use ng-bind-html on your element that you wish to show the data. No need for a filter here. ng-bind-html will convert text to html and will leave plain text alone.

AngularJS html binding

Sign up to request clarification or add additional context in comments.

4 Comments

ng-bind-html isn't new
Yes I did because it is good practice. I see how my sentence is worded though, I will fix that.
the code i am working on belongs to a company i can't simply upgrade it. And opting to not use filter property over ng-bind-html is very big and last choice since the filter is being used all over the place like 30 files.
I see your dilemma, would you be willing to provide the code to the filter? I would like to look at it to see if I can help.

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.