0

我正在做一个角度图表,它具有三个值和显示标签,当我单击图表时,它必须显示我单击的标签。我正在尝试从点中获取值。

 $scope.data = ["prospective","CallBacks","Closed"];
        $scope.labels = ["4","2","3"];
$scope.onClick = function (points,evt) {
    console.log("Points: "+JSON.stringify(points));
  $scope.struct=JSON.stringify(points);
  $scope.value=$scope.struct.label;
    }
<canvas id="pieChart" class="chart chart-pie"
     chart-data="data" chart-labels="labels" chart-legend="true" chart-click="onClick">
   </canvas>
<span>{{value}}</span>

日志显示如下点:

[{"value":4,"outerRadius":95.5,"innerRadius":0,"fillColor":"rgba(151,187,205,0.8)","highlightColor":"rgba(151,187,205,0.8)","showStroke":true,"strokeWidth":2,"strokeColor":"#fff","startAngle":4.71238898038469,"circumference":1.9332877868244882,"label":"Prospective","_saved":{"value":4,"outerRadius":95.5,"innerRadius":0,"fillColor":"rgba(151,187,205,1)","highlightColor":"rgba(151,187,205,0.8)","showStroke":true,"strokeWidth":2,"strokeColor":"#fff","startAngle":4.71238898038469,"circumference":0,"label":"Prospective"},"endAngle":6.645676767209178}]

我可以从日志中获取值,但在 $scope.value 中使用相同的值,标签显示为未定义。

4

1 回答 1

0

感谢各位的支持,似乎有 json 数组,所以当我给 $scope.value=$scope.struct[0].label 时,它工作得很好..

于 2016-03-04T06:43:23.380 回答