I have an angular application where I use the routeprovider which points to different templates. A list template and a map template. These templates have controllers associated to them. The problem is when i change the route, then the current controller instance is destroyed, and a new controller instance for the current template is re-initated. This is a problem because the map template initiates an openlayers map which is quite browser heavy.
Routeprovider:
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/list', {
reloadOnSearch: false,
templateUrl: '/listTpl.html'
}).
when('/map/', {
reloadOnSearch: false,
templateUrl: '/mapTpl.html'
})
.otherwise({
redirectTo: '/list'
});
});
}]);
MapTpl.html
script type="text/ng-template" id="/mapTpl.html">
<div ng-controller="mapController" class="map">
html stuff
</div>
So are there any way to persist these controllers, so the routeprovider just switches between those instances?
Thank you!