繁体   English   中英

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

[英]How to use the get method to call the javascript function in Angular.js?

我正在尝试使用angular将Java脚本函数调用为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();
});
}//]]>

请让我知道我要去哪里错了。 并预先感谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM