0

I have built an application that retrieves data from the WP Rest API V2 with AngularJS. The response contains escaped characters like the one below:

 "excerpt": {
  "rendered": "<p>Når vi handler ind, støder vi på mange forskellige mærkningsordninger, og det kan ofte være svært at finde ud af, hvad de forskellige typer betyder. For at give dig svar på&#8230;</p>\n",
  "protected": false
},

Is there a way unescape the character in Angular? I have looked at multiple options but none seem to work.

The data is displayed in my view like this:

<div class="titlepane">
            <h4 class="posttitle white">
                {{posts.title.rendered}}
            </h4>
            <h4 class="categorytitle white">
                {{categories.name}}
            </h4>
        </div>

You can see the result in the image where the escaped character is shown.

Unescaped Character

How do I solve this?

kristofferandreasen
  • 847
  • 2
  • 12
  • 24
  • I'm pretty sure this is a duplicate of http://stackoverflow.com/questions/20280601/insert-html-in-a-handlebar-template-without-escaping...... But the result image does not match the HTML snippet provided, so it's hard to tell the exact behavior of your issue. – Kyle Martin Feb 16 '17 at 18:31
  • The suggested solution in the referenced question does not solve the problem. – kristofferandreasen Feb 16 '17 at 18:34

1 Answers1

1

I figured it out from another thread. The answer is to use the ng-html-bind. Like the following:

  <h2 class="post__title" ng-bind-html="post.title.rendered"></h2

Then it will show as it is supposed to.

kristofferandreasen
  • 847
  • 2
  • 12
  • 24