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.

4
  • Do you have cache enabled on the route? Commented Aug 3, 2015 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'. Commented Aug 4, 2015 at 9:30
  • Look into the differences between factory and service - stackoverflow.com/questions/13762228/… Commented Aug 4, 2015 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. Commented Aug 11, 2015 at 10:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.