Page should not be refreshed during history back

Hi everyone,

               I need page should not be refreshed during back from a page(history back) and it goes to the same position while i navigate from

Quick help would be appreciated

$ionicConfigProvider.views.forwardCache(true);

where can i use this

angular.module(‘ionicApp’, [‘ionic’])

.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {

//$ionicConfigProvider.views.forwardCache(true);

hi thesourav that’s not working form me when i back to previous page it all refreshes the page

Hi, muraleecse

I just want to ask you, when you came back (click on back button) ,the page will refresh or not.
->if you want to refresh then use

    $scope.$on('$ionicView.enter', function (event, data) {
         if(data.stateName=='app.article'){
                  //call your function here 
         }
     }

-> you don’t want to refresh then, just send here your function where you want to store data to $scope

i doesnt want to refresh the page

Thanks

ok just send here function so, i will check it why it was refresh

ok
$scope.chefList = chefList.data;(array lists)

sessionStorage.setItem(“SessionMessage”, JSON.stringify(chefList.data));setting lists in session storage…

after history back

if (window.localStorage.getItem(‘back’) == 1) {
//for normal listing
//console.log(window.localStorage.getItem(“products”));
$scope.errMsgLbl = { display: ‘none’ };
//console.log(JSON.parse(sessionStorage.SessionMessage));
$scope.chefList = JSON.parse(sessionStorage.getItem(“SessionMessage”));
console.log($scope.chefList);
} else {

}

$window.history.back();

this is i am using for history back

Hi @muraleecse,

I think, for history back you should use a service provided by ionic instead of $window.history.back();

For example,

$scope.goBack = function() {
      $ionicHistory.goBack();
} 

You just need to inject $inonicHistory service in your controller and put the above code in your controller and call goBack() function from the header back button.

In this way your page may also not get refreshed.

Hope this will help you.

thank you addwebsolution for your reply

I will try it

Ok and if it helps you then you can always like the answer by clicking heart button.

The smallest piece of efforts is always appreciated! :slight_smile:

yes sure
i will do it

it throws Unknown provider: $ionicHistoryProvider

Have you injected $ionicHistory in your controller?

yes after i added in controller only it throws error

this is my code

appp.run(function ($ionicPlatform, $location, $ionicPopup, $rootScope, $state, $ionicSideMenuDelegate, $window, $ionicHistory) {

@muraleecse

This is your app.run() function which will call at the time of initialization of the application.

Please add $ionicHistory in the controller fuction.

appp.controller(‘backcontroller’, [’$ionicHistory’, function ($ionicHistory) {

like this right?