So i try to create directive for leaflet.js, when i use factory inside directive, everything works just fine
(function() {
'use strict';
angular
.module('directoryAppMap')
.directive('leafletDirective', function (Directory) {
return {
restrict: 'EA',
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);
Directory.get(function (data) {
L.geoJson(data).addTo(map);
});
}
};
});
})();
In my controller i do some stuff and pass it to view
$scope.geojson = {};
$scope.FilteredGeojson = function () {
var result;
result = $filter('filter')($scope.data, $scope.search);
result = $filter('offset')(result, $scope.currentPage * $scope.pageSize);
result = $filter('limitTo')(result, $scope.pageSize);
$scope.geojson = result;
return result;
};
Everything works fine in table i use ng-repeat with FilteredGeojson() but when i try to pass $scope.geojson to directive, angular start infinite digest loop and map is without any geojson
to previous directive i use add
scope: {
data: '='
}
in view i pass
data="geojson"
unfortunatelly i cannot use leaflet directive for angular, because with to many markers is very slow