我创造了一个 漏斗 </跨度> java脚本中的图表。并转换为angular现在我正在尝试使用angular中的http.get方法来获取json数据。我被困在这里,并在……这一部分感到困惑
现在让我告诉你我的代码部分
— — index.html的
&lt;!DOCTYPE html&gt;&LT; HTML&GT;&LT; HEAD&GT; &lt; meta http-equiv =“content-type”content =“text / html; charset = UTF-8”&gt; &lt; title&gt; FusionCharts - 漏斗 </跨度> 3D ……
看来你只是将错误的参数传递给dataSource字段。经过一些玩弄你的羽毛球, 的 而不是传递一个执行$ http调用的函数,我传递了数据本身 强> ,如下所示。
var myApp = angular.module("myApp", []); //The below code will read the data from student.json file and will pass to the $scope variable myApp.controller("ParentCtrl", function($scope, $http) { $http.get('./chart.json') //reading the studentRecord.json file .success(function(data1) { $scope.dataSource = data1; // binding the data to the $scope variable FusionCharts.ready(function() { //alert("1"); var conversionChart = new FusionCharts({ type: 'funnel', renderAt: 'chart-container', width: "100%", dataFormat: 'json', dataSource: $scope.dataSource }); conversionChart.render(); }); }); });
注意我将代码包装在$ http的成功回调中,这样我们就知道数据在渲染时就存在了。
你可以看到工作的plunker 这里 。