Reputation: 65
I have found this angular directive Directive
but when i create two identical charts It crashes, and I can not add charts.
The problem is that the Directive, generate random id .
Is there a way to write directly in the scope?
Thank you!
UPDATE(1)
I have an array of chart : for example
$scope.charts = [
{
name:"Simple Pie Chart",
image:"/theme2/assets/img/widget2.png",
"struct":{
"type": "pie",
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",
"titleField": "category",
"valueField": "column-1",
"allLabels": [],
"balloon": {},
"titles": [],
"data": [
{
"category": "category 1",
"column-1": 8
},
{
"category": "category 2",
"column-1": 6
},
{
"category": "category 3",
"column-1": 2
}
]
}
}
When user select one of this charts I add it in a variable->
$scope.items.push(data.item); //chart selected
and then in the html i display the selected charts with the
Directive :
<div ng-repeat="graph in items">
<amchart ng-model="graph" >
</amchart>
</div>
Upvotes: 1
Views: 726
Reputation: 13917
i guess the ng-repeat
is crashing because of duplicate items...not the chart
try ng-repeat="graph in items track by $index"
this will allow you to have duplicate objects in your repeater.
Upvotes: 0