score:3

Accepted answer

that is because when you define a scope object in your directive, it creates an isolate scope for that directive. that means, the scope within your directive cannot access the scope properties defined outside. you have your controller defined on the outer scope where you attach the function updatechart. so, your isolate scope directive is not aware of this method.

to fix this, you can define a controller on your directive itself. and in that controller, define the method updatechart

.directive('changechart', function() {
  return {
    restrict: 'e',
    scope: {
        name: '@'
    },
    controller: function ($scope) {
        $scope.updatechart = function(id, type) {
            var chart = $('#' + id).highcharts();
            chart.series[0].update({
                type: type
            });
        };
    },
    templateurl: "change-chart.html"
  };
})

Related Query

More Query from same tag