Chartjs-Where is the appropriate place to instantiate a javascript widget/chart/utility when using angular.js?

1👍

under the link property.

<script>
    angular.module('app')
    .directive('ngChart', function(){
        return {
            restrict: 'E',
            link: function (scope, element, attrs, controllers) {
                //your plugin implementation here
                data = {...} // dictionary of chart data, omitted for brevity
                options = {...} // dictionary of chart options, same^
                var ctx = element.getContext("2d");
                var chart = new Chart(ctx).Line(data, options);
            }
            template: '<canvas></canvas>'

        }
    )
</script>

Leave a comment