My Directive
angular
.module('directoryAppMap')
.directive('leafletDirective', function () {
return {
restrict: 'EA',
scope: {
data:'=' //I try to pass data by this scope//
},
replace:true,
template:'<div></div>',
link: function (scope,element, attrs) {
var map = L.map(attrs.id, {
center: [40, -86],
zoom: 2
});
//create a CloudMade tile layer and add it to the map
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
maxZoom: 18
}).addTo(map);
scope.ho = ["geometry": { "type": "Point", "coordinates": [ 2.0, 2.0 ] } },
{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 1.0, 1.0 ] } },
];
L.geoJson(scope.ho).addTo(map);
}
};
});
But when i Try to pass data from my view
<tr ng-repeat="hf in (FilteredGeojson = (ho))">
<div leaflet-directive id="map" data="FilteredGeojson"></div>
The scope is the same, the difference is that i initialize it in controller not in directive and then when i pass FilteredGeojson to leaflet it show me invalid geojson object.
I even throw away all filters in order to just pass some data, Maybe i do something wrong with directive and global scope?
My geojson is valid i check it plenty of times, should i pass data to leaflet in some other way? For me is important that map and table are integrated dynamically.