[Chartjs]-Why is my dependency injection not working in Angular?

1๐Ÿ‘

โœ…

Include angular-chart.min.js and Chart.min.js before angularApp.js in your html.

And there is no need to include chart.js in controller parameters.

angularApp.controller('wallPosts', ['$scope', function($scope){

    $scope.labels = ["Download Sales", "In-Store Sales", "Mail-Order Sales"];
    $scope.data = [300, 500, 100];

}]);

1๐Ÿ‘

I think the problem is with the chart.js you have injected in the controller . remove it from the controller injection then try it .

1๐Ÿ‘

Your are injecting chart.js in your controller is not correct, please check the below code..
Eg:

 angularApp.controller('wallPosts', function($scope){

    $scope.labels = ["Download Sales", "In-Store Sales", "Mail-Order Sales"];
    $scope.data = [300, 500, 100];

}]);

For more understanding : http://jtblin.github.io/angular-chart.js/

Leave a comment