I have a directive where I am putting graphics, but I can not understand how I can pass Array
from controller
to this directive or how can I get that Array
using $ http within the directive.
This 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 Array
pieData with static data, I would like to briefly pass this data through controller
or capture them in the directive itself using $http
. How can I do this?