I m trying to create angular directive for highmaps.
Below is my code
var myMapDirectives = angular.module('MapDirectives', ['myMapControllers']);
// Directive
myMapDirectives.directive('myMap', function($http) {
console.log("In my-Map directive");
return {
restrict: 'EAC',
template: '<div></div>',
replace: true,
controller: 'myMapController',
scope: {
widget: '='
},
link: function(scope, iElement, iAttrs) {
console.log("In my-map link function.", scope, iElement, iAttrs);
var chart;
var process = function(){
var defaultOptions = {
chart: {
renderTo: iElement[0]
},
};
var widget = angular.extend(defaultOptions, scope.widget);
chart = new Highcharts.Map(widget);
};
process();
scope.$watch("widget.series", function(loading){
process();
});
scope.$watch("widget.loading", function(loading){
if(!chart){
return;
}
if(loading){
chart.showLoading();
} else {
chart.hideLoading();
}
});
}
};
});
The controller is bit large as I put all the JSON data in mapData
attribute.
Here my code is available Highmaps Directive & Controller.
The problem Map is not displaying.
(I follow this link to create the directive Plunker )