in my application controller I make a request to my api. It looks like this :
.state('state1', {
url: '/datas/:id',
templateUrl: 'myurl.com',
title: 'title',
controller: function($http, $rootScope, $location, $stateParams){
var id = $stateParams.id;
$http.post('http://' + $location.host() + id, {id: id } , {})
.then(function(d){
$rootScope.data = d.data;
},
function(err){
console.log(err);
});
},
})
my d3 script is something like this :
<script>
...
var force = d3.layout.force().size([width, height]).on("tick", tick);
var svg = d3.select("#d3g").append("svg").attr("width", width).attr("height", height);
var link = svg.selectAll(".link"),
node = svg.selectAll(".node");
...
...
d3.json("data.json", function(error, json) {
if (error){
console.log(error);
}
...
...
</script>
How can I pass data I receive from api (in the controller) to my d3 display (in and html file).