Quantcast
Channel: Is there a way to load data into script - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Pankaj Parkar for Is there a way to load data into script

$
0
0

You could create a directive that will load the script into DOM dynamically.

Markup

<load-script ng-if="data" data="data"></load-script>

Directive

app.directive('loadScript', function($compile){  return {    restrict: 'E',    scope: {'data': '='    },    link: function(scope, element, attrs){      element.append($compile(scope.data)(scope))    }  }})

Working Plunkr


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>