Dynamically Injecting Script Tags With AngularJS
Posted by: K. Scott Allen,
on 08 Apr 2014 |
View original | Bookmarked: 0 time(s)
A few months ago I found myself in a situation where I had to throw some dynamically generated scripts into the browser for testing (and occasionally inspecting and debugging). I wrote a small custom directive to take care of most of the work. <div ng-controller="mainController">
<div otc-scripts scripts="scripts">
In the above markup, its the mainController that will fetch the script text for execution, which Ill simulate with the code below....