html - AngularJS Prevent Browser Escaping Characters -



html - AngularJS Prevent Browser Escaping Characters -

i created directive highlights code seems browsers modifying code before can , highlight it.

here's what's happening.

i have directive called my-compile spits passed value element's innerhtml , runs $compile on it.

eg:

<span my-compile="details"></span>

and details like:

here details , here's <code lang="java">first = temp & 0xff &amp;</code>

here's directive code matters (this in link function):

element.html(details); $compile(element.children())(scope);

so $compile sees <code> directive , hands off code directive, except, , here's problem, <code> directive element.html() contents , returned:

first = temp &amp; 0xff &amp;

the problem code wrong, because first & wasn't escaped.

how can still utilize <code> directive in similar fashion preserve & sign (and assume happens > , < signs too)?

my thought lookup service that's kinda messy, maybe alternative sec hits browser's dom gets escaped, escaped & doesn't double escaped.

i've tried using element[0].innerhtml thinking maybe it's angular/jquery sanitization thing, it isn't.

the problem when added html dom first time element.html(details); browser parses html(btw - fixes wrong escaping, adds missing close tags, etc), , when trying access later - getting html fixes done during parsing.

the way how can prepare - encode code content text entity(for provided illustration if need text first = temp & 0xff &amp; encoded version first = temp &amp; 0xff &amp;amp;), access element.text() not element.html() in code directive.

html html5 angularjs angularjs-directive

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -