Show last content with back button

I’ve got list with search filters and remote data. After clicking item details occur.
When I press back button I want to show the same list (the same filters applied) without loading it from Internet.
Is it possible?

AppCtrl.controller('atrakcjeCtrl', function($scope, App, $http) {
  var params = App.getParams();
  if (params) {
	$scope.filtry = {};
	if (params.bliskoCiebie) {
	  var geoLokalizacja = App.getGeoLokalizacja();
	  $scope.filtry.x = geoLokalizacja.x;
	  $scope.filtry.y = geoLokalizacja.y;
	} else {
	  if (params.x)
		$scope.filtry.x = params.x;
	  if (params.y)
		$scope.filtry.y = params.y;
	$scope.filtry.rodzaj = '';
	$scope.filtry.sortuj = 'odleglosci';
	$scope.filtry.w_promieniu = 50;

	$scope.pobierzListeAtrakcji = function() {
		method: "POST",
		url: App.getPsURL() + "atrakcje.php",
		data: this.filtry
	  }).success(function(data) {
		$scope.atrakcje = data;

You need to use a service for this. You $http method in the controller will never allow you to “cache” the results. It will be fired every time.

So, create a service. When the controller first queries the service, the service will store the results in a variable. The next time the controller is loaded, it needs to ask the service for the data again. Then, if the service has any data stored, it will provide it, otherwise, it will query the API again.

Here is an example of using a service :

Hi @Calendee, was reviewing your service example above and it looks to me that MovieService.get is what actually emulates a real api query and not MovieService.getSync which merely returns the js object. How would you actually go about caching your service results in a real app? Would you opt for something like angular-cache or merely store results in localStorage the first time you hit your service and load from localStorage subsequently so that the app can work just fine offline?
Take something like Twitter app as an example.

It depends on the purpose of the “cache”. If you don’t need it for offline use, I’d just put it in a variable. Then, it will exist for the life of the app. If the app is completely closed, it will be destroyed. Otherwise, it will be available as long as the app stays open.

If you need real persistence or expirations or more features, then localStorage or Angular-cache(which is what I use.

So tip for next feature - load view from last cache when pressing back button.
Now I have to recreate last state of view :confused:

I looked at Angular-cache ( and I have to say a bit of work with that.
I think that option would be very useful.
Can we have hope that You include posiibility “load view from cache when pressing back button” in near future?

There is a feature request in for this already.

Issue # 721 : and
Issue # 714 :

Great news! Looking forward