how to empty reference object in angular js?

风流意气都作罢 提交于 2019-12-08 09:39:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!