0

I have a flow of few pages/views starting from first page to last page. This is pretty much based on the Ionic tutorial.

I update a factory "Info" with some data as I proceed with the flow. In the final page, after displaying the "summary info" to the user, I use $state.go('firstPage') to navigate back to the first page.

When I make a different selection in the first page this time, it doesn't seem to take effect in the view.

I tried the suggestion from here but that didn't help me. I tried resetting the variables again, but that doesn't help either.

angular.module('my.services', [])
    .factory("Info", function(){
        // All user data
        var infoData = {
            type: "",
            level: 0
        };
    var originalInfoData = angular.copy(infoData);
    // Reset data
    infoData.resetUserDetails = function() {
        userData = angular.copy(originalInfoData);
    };

Final Page Controller

$scope.finish = function() {
    UseInfo.resetUserDetails();
    $state.go('firstPage');
}

This takes me back to first page but even though I select something different this time, the pages seem to remember what I did in my first run.

The question is - how do I clear things up so the user can do something else after getting back to the first page without remembering previous selections.

Cœur
  • 32,421
  • 21
  • 173
  • 232
Andy
  • 753
  • 1
  • 6
  • 17
  • Do you have `cache` enabled on the route? – Brett DeWoody Aug 03 '15 at 18:09
  • They are enabled by default (just found out). I disabled them in the states and it seems that the scope variables behave better. The data in 'infoData' however retain the values even though I have tried resetting them using angular copy and literally over-writing them with original values in 'resetUserDetails'. – Andy Aug 04 '15 at 09:30
  • Look into the differences between factory and service - http://stackoverflow.com/questions/13762228/confused-about-service-vs-factory – Brett DeWoody Aug 04 '15 at 16:20
  • For closure, caching was one issue. Next was that I needed {reload: true} when I switched the state. That fixed the issues I was having. – Andy Aug 11 '15 at 10:23

0 Answers0