Monday 15 April 2013

ng-bind-html-unsafe not parsing html in angularjs -


I'm a little bit of a weird time with angular parsing the HTML given in Jasonson. I am using ng-bind-html-unsafe instructions which takes strings from JSON and output it to the page, but the browser is not being parsed by the browser.

I am using angularjs V1.1.5, but the older versions have also tried.

My binding tag looks like this:

  & lt; Div class = "announcement-wrapper" ng-repeat = "declaration announcements" id = "{{announcement.announcementId}}" & gt; & Lt; P ng-bind-html-unsafe = "declaration.content" & gt; & Lt; / P & gt; & Lt; / Div & gt;   

and JSON is feeding compulsory:

  {"userId": "s123456", "response code": "right", "feedback message" : "", "Timestamp": 1371778685560, "Announcements": [["Declared": 1518, "Title": "Second Declaration of Dave", "Content": "amp; l & gt; Chad End "June 13, 2013", "Important": Wrong, "Read": True}, {"Declaration": 1511, "Title": "Oshher O and TAFE Declaration", "Content": "& amp; & L> P & gt; This announcement is only for Onshore O and TAFE coastal people. & Amp; lt; / p & gt; & lt; p & gt; Uch Wrong priority "] is correct.}}}     P> What's happening is that the encoded characters are being produced on the page, it's just that they are not being parsed by the browser for output as an actual paragraph tag. like. Output is being posted on the second announcement page  
  & lt; P & gt; This announcement is only for ONSHOR HE and TAFE individuals. & Lt; / P & gt; & Lt; P & gt; high priority. & Lt; / P & gt;   

I have tried to use NG-Bandh-HTML instructions and there is cleanliness dependency in place of it and it will not work either together. There is no doubt that it is small, but I just need a fresh eyes to look ...

Thanks in advance!

This is because you are using & amp; L <; Code> and & amp; Gt; are used to open and close brackets.

Instead of opening and closing the tags, they will use less and larger than the symbol

You announcements.content is less than symbols and To be replaced with more:

  ... "content": "& lt; p> Announcement for Chad ", ...   

Edit: You might see a list of all HTML codes in the "& lt;" Are using HTML code and "& gt;" And thus instead of opening and closing the tag, you get that character.

No comments:

Post a Comment