Sunday, May 19, 2013

AngularJs and Xml in IE8

Directives are the backbone of AngularJs.  They are perfect for working with Xml.  Internet Explorer 8 does not render Xml on the DOM correctly.  My quick fix is to use ng-include.  I've probably blogged about this before.  But today I lost an hour of time working on a sample page for a very complex directive.

On my second pomodoro break, I decided to look at the xml.  It looked fine.  Then I put it in a separate file, used ng-include and it worked perfectly in IE8.  It always worked in Chrome.  I usually develop in Chrome then work through any IE8 issues. This process speeds up my development cycle.

<div ng-include="'myfile.xml'"></div>
Be sure to use single quotes around the file name.

Note: you can also load files dynamically with ng-include.

No comments:

Post a Comment