Escaping double double quotes in html attributes in Javascript Escaping double double quotes in html attributes in Javascript angularjs angularjs

Escaping double double quotes in html attributes in Javascript


If it is HTML, you can use HTML entities to escape characters that might be interpreted otherwise. For example, " will be displayed as " in HTML attributes:

var content = '<input type="text" ng-model="test1" />';

Proof of concept: http://jsfiddle.net/teddyrised/5X5Ye/

Refer to W3C's HTML entities chart for more information: http://dev.w3.org/html5/html-author/charref