So I have this script tag that I want to add into my angular project:
<script>
var data = [4, 8, 15, 16, 23, 42];
var x = d3.scale.linear()
.domain([0, d3.max(data)])
.range([0, 420]);
d3.select(".chart")
.selectAll("div")
.data(data)
.enter().append("div")
.style("width", function(d) { return x(d) + "px"; })
.text(function(d) { return d; });
</script>
I've been trying to figure out what the best way to add this snippet into my angularjs app. I saw this here: render <script> tag in angularjs but this question was asked a while ago, so I wanted to see if there was a better (newer) way to accomplish this. I initially added it to my view but i'm not able to pass any data from my controller into the block. For example, I wanna do something like:
var data = {{someArray}};
But i end up getting an error:
SyntaxError: Unexpected token {
I'm trying to figure out the best approach to this. Would it be best to just follow the example in the link above? Let me know what you all think, thanks!