如何使用get方法调用Angular.js中的javascript函数?

时间:2015-07-06 07:29:50

标签: javascript html angularjs get

我试图将java脚本函数调用为使用angular的get方法。主要概念是创建一个包含java脚本代码的漏斗图。我需要使用get方法获取函数。

这是我的index.html

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>FusionCharts - Funnel 3D Chart in JavaScript Example - jsFiddle demo by fusioncharts</title>

  <script type='text/javascript' src='/js/lib/dummy.js'></script>

  <link rel="stylesheet" type="text/css" href="/css/normalize.css">

  <script data-require="angular.js@1.4.0-beta.6" data-semver="1.4.0-beta.6" src="https://code.angularjs.org/1.4.0-beta.6/angular.js"></script> 

  <link rel="stylesheet" type="text/css" href="/css/result-light.css">


      <script type='text/javascript' src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>



      <script type='text/javascript' src="http://static.fusioncharts.com/code/latest/fusioncharts.widgets.js"></script>



      <script type='text/javascript' src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
    <script src="practice.js"></script>

  <style type='text/css'>

  </style>






</head>
<body ng-app="myApp">
  <!-- A funnel 3D Chart showing a conversion analysis in percentage of visiting to purchase in Harry's Supermart website last year 

Attribute :
# showPercentValues - set to 1 to show the values in percentage.

-->

<div id="chart-container" ng-controller="ParentCtrl"  ng-repeat="person in students">FusionCharts will render here</div>

</body>


</html>

---- ----的script.js

// Code goes here

//creating an application module
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('data/chart.js') //reading the studentRecord.json file
            .success (function(data){
                $scope.students = data; // binding the data to the $scope variable
        });

    }
);

- - - - - - - - chart.js之

window.onload=function(){
FusionCharts.ready(function () {
    var conversionChart = new FusionCharts({
        type: 'funnel',
        renderAt: 'chart-container',
        width: "100%",
        dataFormat: 'json',
        dataSource: {
            "chart": {
                        "caption": "Ensource sales report",
                        "subcaption": "Purchase - Conversion analysis for last year",
                        "decimals": "1",
                        "isHollow": "0",
                        "isSliced": "1",
                        "labelDistance": "15",
                        "plotTooltext": "Success : $percentOfPrevValue",
                        "theme": "fint",
                        "baseFontSize":"18"
            },
                "data1": [

                                        {
                                            "label": "Total",
                                            "value": "385634"
                                        },
                                        {
                                            "label": "Contacts",
                                            "value": "175631"
                                        },
                                        {
                                            "label": "Leads",
                                            "value": "84564"
                                        },
                                        {
                                            "label": "Sanctioned",
                                            "value": "35654"
                                        },
                                         {
                                            "label": "Disbursed",
                                            "value": "12342"
                                        }

            ]
        }
    });

    conversionChart.render();
});
}//]]>

请让我知道我哪里出错了。并提前感谢。

0 个答案:

没有答案