Michalis
Michalis

Reputation: 6926

AngularJS - bind-html to input

I have a json file with same values that have special chars. Also i have a var that I use as a model to input,textarea

<input ng-model="textVar" type="text" />
<textarea ng-model="textVar"></textarea>

textVar = "Raspberry Pi's Impact on Hacking"

but to input it shows... "Raspberry Pi&#39 ;s Impact on Hacking" when i want to simple echo this string i use and everything is ok... but now... i have input and textarea. What can i do?

Upvotes: 1

Views: 392

Answers (1)

Pogrindis
Pogrindis

Reputation: 8091

Can you show us your request ?

Encoding looks wrong.

transformRequest: function (data, headersGetter) {
    return encode_utf8(JSON.stringify(data));
}

function encode_utf8(s) {
  return unescape(encodeURIComponent(s));
}

Something like this should clean up your JSON.

You are putting from plaintext into HTML and into your JSON. This result is expected.

If you need to include other string literal you can place them inside single quotes (’). If single quote ’ character need to be displayed, then you have to escape it using doubling the character ’.

Upvotes: 1

Related Questions