0

i'm using an ng-repeat directive to show a list of posts, retrieved through a wordpress-json-api.

i have problems with some characters, as the output of wp-json-api escapes some of them.

myjson :

 {
 "id": 1,
 "type": "mynicetype",
 "slug": "myniceslug",
 "title": "It’s a strange char" //my apostrophe got changed
 ... }

and my markup:

<li ng-repeat="post in menu.posts | filter:searchText | filter:query" >
   <h4 >name : {{post.title}}</h4>
</li>

get rendered (obviously-awfully) as

name : It&#8217;s a strange char 

What's the best approach for formatting these html numbers? (before assigning the json.success data to the scope or, more easily, on the fly, inside template? but how?)

(btw i don't get the reason why an apostrophe should receive a special treatment by a json-api, but i could really be misunderstanding something here)

Thanks for any clarification

urka_mazurka
  • 138
  • 1
  • 11
  • It's two part solution look for `ng-bind-html` and `$sce` – Shanimal Jun 24 '14 at 16:47
  • the answer is here: http://stackoverflow.com/questions/21919533/using-html-entities-within-angular-strings – Jonathan Wilson Jun 24 '14 at 16:47
  • possible duplicate of [With ng-bind-html-unsafe removed, how do I inject HTML?](http://stackoverflow.com/questions/19415394/with-ng-bind-html-unsafe-removed-how-do-i-inject-html) – Shanimal Jun 24 '14 at 16:48
  • thanks for pointing to right resource (i finished using Alex's solution there, as i was not able to use accepted solution.. still have a lot of things to learn about angularjs). but rocks! – urka_mazurka Jun 25 '14 at 00:05

0 Answers0