Eval script elements through Ajax calls?

Hi guys,

I’m trying to build an app with Ionic. This app would use HTML5 canvas element, with a 3rd party JS library to handle it. To do this, I’d need use HTML script elements. When a tab (for instance) is loaded, Ionic loads it through an Ajax call, but script elements don’t get evaled.

Is there a way to make Ionic eval this javascript code ? I’m not sure if it’s related to Ionic or Angular though…

Thanks for your help.

Can you post a codepen demo of what you have so far?

By any chance did you used to use JQuery? :stuck_out_tongue:

You may want to rethink your solution and use something like a directive to accomplish this.

Something like this should get your started,


Thank you guys for your replies. I’m not familiar with codepen, I’m not sure I can simulate an ajax call and deal with different html pages. I’ll see what I can do. Just to explain more: I took the ionic tutorial, and put a script element in www/template/tabs-account.html.

I’ve been able to test canvas with a work around: all scripts elements are declared in index.html, and angularjs’s controller run entry code. As a test, I used this page: http://www.openxrest.com/demos/balls/, based on paper.js + a physics library (that’s what I’d need) It appears it gets really slow (tested on an old galaxy note 1). I’m not sure it’s reasonable to go this way (html5, hybrid app)… Any thoughts ? Should I stay native for this kind of app ?