问题
I am trying to empty my reference object .But it is not deleting or removing my chart . I make two directive and communicate with shared service.But then I delete my reference object .it not deleted my chart ..on click of "delete" button i need to delete my chart .. is it possible ?because I take reference objects
here is my code
http://plnkr.co/edit/TzUlqoh4sYVjH3ADRTGL?p=preview
angular.module('app',['header','chartm','hig']).controller('cntrl',function(){
}).service('sharedService',function(){
var vm =this;
vm.chartData={};
vm.displatChart=displatChart;
vm.deleteChart=deleteChart;
function deleteChart(){
vm.chartData={};
}
function displatChart() {
var orderData = {
chart: {
type: 'bar'
},
title: {
text:'Order Execution Status '
},
colors: ['#2f7ed8','#910000','#8bbc21','#1aadce'],
xAxis: {
categories: [1,2,4]
},
yAxis: {
min: 0,
title: {
text: ''
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [ {
name: 'Excecuted',
data: [1,2,3]
},{
name: 'Placed',
data: [4,3,2]
}]
};
vm.chartData=orderData;
return vm.chartData;
}
})
Update
If I do wrong in architecture please provide me good way to do this task ?
I try another way i am able to delete but not generate again
http://plnkr.co/edit/TzUlqoh4sYVjH3ADRTGL?p=preview
vm.delete=function(){
alert('delete');
sharedService.deleteChart();
$('#myChart').html('')
}
vm.add=function(){
alert('add');
sharedService.displatChart();
}
any update ?
来源:https://stackoverflow.com/questions/34431114/how-to-empty-reference-object-in-angular-js