1
I have a directive where I mount some graphics, but I’m not getting to understand how I can pass a Array of controller for this directive or so how can I catch this Array using $http within the directive.
That is the directive:
.directive('pieDonut', function(){
        return {
            restrict: 'A',
            link: function(scope, element, attrs){
                var pieData = [
                    {data: 40, color: '#F44336', label: 'Negadas'},
                    {data: 43, color: '#03A9F4', label: 'Aprovadas'},
                ];
                /* Pie Chart */
                if($('#pie-chart')[0]){
                    $.plot('#pie-chart', pieData, {
                        series: {
                            pie: {
                                show: true,
                                stroke: {
                                    width: 2,
                                },
                            },
                        },
                        legend: {
                            container: '.flc-pie',
                            backgroundOpacity: 0.5,
                            noColumns: 0,
                            backgroundColor: "white",
                            lineWidth: 0
                        },
                        grid: {
                            hoverable: true,
                            clickable: true
                        },
                        tooltip: true,
                        tooltipOpts: {
                            content: "%p.0%, %s", // show percentages, rounding to 2 decimal places
                            shifts: {
                                x: 20,
                                y: 0
                            },
                            defaultTheme: false,
                            cssClass: 'flot-tooltip'
                        }
                    });
                }
            }
        }
    })
At the beginning of the directive I have the Array pieData with static data, briefly I would like to pass this data through the controller or capture them in the directive itself using $http. How can I do that?
Opa, thanks a lot @lbotinelly, I found it really cool
$observe– DiegoAugusto
@Techies always a pleasure to help. =)
– OnoSendai