如何使高图可点击?

时间:2015-10-14 11:05:08

标签: html angularjs highcharts angularjs-routing angularjs-ng-click

我在html div中渲染图表。

<div ng-click="changeRoute()" class="funcList">
    <div high-chart chart_object="options"></div> 
</div>

在js我有 -

 $scope.changeRoute = function(){
    $location.path(/*path i want to redirect*/);
  }

但是,我在div上给出的ng-click不起作用,因为highcharts与div位置重叠。

所以,我在高潮图上写了点击事件 -

scope.options.chart.events.click =function(event) {
     $scope.changeRoute();
 };

这里发生的事情是 - 在点击图形时调用changeRoute方法,但它不会将其重定向到预期路线。 //如果我删除了图表,那就行了。

对此有何解决方法? (我希望整个div可点击) 感谢

2 个答案:

答案 0 :(得分:0)

A fiddle with example

   function changeRoute(){
   alert("hello");
  window.location.href="http://code.highcharts.com/modules/drilldown.js";
}

在加载事件中调用此函数

 chart: {
            type: 'column',
            events :{
                click: function(){changeRoute();}
            }
        }

答案 1 :(得分:0)

这是$ location.path的问题。 Angular并不总是认识到有变化因此它永远不会消化。 所以有时我们必须在$ location.path之后显式调用$ scope。$ apply()。

相关问题