I set up a factory provider for my graph. The graph is built from highcharts and highcharts-ng which is an angularjs highcharts directive.
Within my controller named SentimentChartController I then created a click function on my graph nodes as follows:
$scope.AveSentimentChartConfigMain.options.plotOptions.series.point.events.click = function () {
var containerDiv = document.createElement('div');
containerDiv.setAttribute('id', 'postListPopUpContainer');
containerDiv.setAttribute('ng-controller', 'SentimentChartController');
var contentDiv = document.createElement('div');
contentDiv.setAttribute('id', 'postListPopUp');
contentDiv.innerHTML = '<img onclick="closeDrillDown()" src="images/closePostListPopUp.svg" title="Click to close" class="closeIcon" width="18" height="18"><h2>' +
this.category + ' ' + this.series.name + '</h2>' +
'<p class="drillDownInfo"><strong>' + this.y + '%</strong> of posts where we can determine a sentiment are ' + this.category + '</p>';
document.body.appendChild(containerDiv);
containerDiv.appendChild(contentDiv);
};
The html generated once you click on a graph node is as follows:
<div id="postListPopUpContainer" ng-controller="SentimentChartController">
<div id="postListPopUp">
<img src="images/closePostListPopUp.svg" title="Click to close" class="closeIcon" width="18" height="18" onclick="closeDrillDown()">
<h2>Positive Sentiment</h2>
<p class="drillDownInfo"><strong>26%</strong> of posts where we can determine a sentiment are Positive</p>
</div>
</div>
In my SentimentChartController I also declared the following function:
$scope.closeDrillDown = function() {
alert('function called');
};
This function should fire onclick of the following img element which is created during my click function defined above
<img onclick="closeDrillDown()" src="images/closePostListPopUp.svg" title="Click to close" class="closeIcon" width="18" height="18">
However I get a "Uncaught ReferenceError: closeDrillDown is not defined" error.
Why is this happening even though I set up ng-controller="SentimentChartController" in my container div