Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


how to load google charts in angularjs


how to load google charts in angularjs  using -'share'

I want to create a directive that can be feed with data from a controller, and show google charts. But the following does not work:

<div google-chart gdata="test"></div>

angular.module('test').controller('myController', myController);

function myController($scope) {

    $scope.test = [
                 ['one', 'two', 'three'],
                 [1,2,3],
                 [4,5,6]
             ];
    });
};

angular.module('test').directive('googleChart', function() {
    return {
        restrict: 'A',
        replace: true,
        scope: {
            gdata: '='
        },
        link: function($scope, $elm, $attr) {

            console.log(gdata);
                var data = new google.visualization.arrayToDataTable(gdata);

                var chart = new google.visualization.LineChart($elm[0]);
                chart.draw(data, options);
        }
    }
});

google.load('visualization', '1', {packages: ['corechart']});


The console prints undifined and shows an error Error: gdata is not defined.

Why is gdata not defined? I have in the the div tag as well as in scope of the directive.?
    

asked Oct 13, 2015 by nimisha.jagtap
0 votes
2 views



Related Hot Questions



Government Jobs Opening


...