I use an angular service for rendering a map and I injected it into my controller. By using ui.router, when I go to map page for first time, the map renders successfully, but when routing to other page and come back to map page again, the map does not renders, and I should refresh the page for it. I used both factory and service for it, but still there is a problem! Any idea? Here is my service and controller:
angular.module('app')
.service('mapService', function () {
var _map = new ol.Map({
target: 'map-canvas',
renderer: 'canvas'
});
this.map = function () {
return _map;
};
}
.controller("mapCtrl", ["$scope", "mapService", function($scope, mapService) {
var map = mapService.map();
}]);