How do I manipulate IONIC3's Internal page history?












0














I've been building an Angular4/Ionic3 application but I've run into a bit of a stumbling block related to browser history and Ionic's history related quirks.



First, a little background info. My application uses navCtrl.SetRoot() for all of its page transitions because .pop() and .push() didn't play well with refreshing the browser page. In the process of development I have made note of a quirk with Ionic navigation: If you go from Page1 to Page2 then try to go Page1 again (using .SetRoot("Page1")) Ionic will look at its history and notice that you were at Page1 just before Page2 so it will decide go backwards in the browser history instead of making a new instance of Page1 in the history. At the end of the .SetRoot("Page1") operation, the history will look like '->Page1<- Page2' rather than 'Page1 Page2 ->Page1<-'.



Now, this isn't normally a problem, but I've noticed that Ionic's Internally stored history is divorced from the browser history. So, if Ionic's history is ever different from the browser's history problems can start happening. For example, if you refresh the page then the browser history stays the same, but Ionic's history becomes a list containing only the current page in it.



E.X.




  1. If we go from Page1 to Page2 to Page3 then refresh
    Browser History: 'Page1 Page2 ->Page3<-'
    Ionic History: '->Page3<-'


  2. Now we go to Page 2 by pressing the browser back button
    Browser History: 'Page1 ->Page2<- Page3'
    Ionic History: 'Page3 ->Page2<-' (Because it didn't find an instance of Page2 before Page3 in its history, it makes a new instance and puts it at the top of the stack instead)


  3. Now we SetRoot("Page3"). Because Ionic History thinks it needs to go back to get to Page3 it will force the browser History to go back as well to try to keep things matched up.
    Browser History: '->Page1<- Page2 Page3'
    Ionic History: '->Page3<- Page2'


  4. Result: Because the url changed due to the browser History now being on Page1, an extra unwanted transition will trigger that will take us to Page1 when we wanted to go too Page3.



Just to make it absolutely clear: The Ionic History I am talking about is something I believe exists due to the behavior of my application. I have never actually seen where it is stored. In addition, I know for sure that the Ionic History is different from the NavCtrl Navigation Stack because my application only uses .SetRoot(), so the Navigation Stack is only ever an array of length 1 containing only the current Page.



With all of that said, here is my question:



Is there a way to access and manipulate the Ionic Framework's internally stored history? At the very least is there a way to wipe it?



Thanks.










share|improve this question






















  • Hmm have you tried the remove method for clearing the NavControllers stack?
    – Phonolog
    Nov 17 '18 at 16:03










  • @Phonolog Since I use SetRoot for all of my page transitions, the NavController's stack only ever has the current page in it.
    – Tywana60
    Nov 18 '18 at 20:22
















0














I've been building an Angular4/Ionic3 application but I've run into a bit of a stumbling block related to browser history and Ionic's history related quirks.



First, a little background info. My application uses navCtrl.SetRoot() for all of its page transitions because .pop() and .push() didn't play well with refreshing the browser page. In the process of development I have made note of a quirk with Ionic navigation: If you go from Page1 to Page2 then try to go Page1 again (using .SetRoot("Page1")) Ionic will look at its history and notice that you were at Page1 just before Page2 so it will decide go backwards in the browser history instead of making a new instance of Page1 in the history. At the end of the .SetRoot("Page1") operation, the history will look like '->Page1<- Page2' rather than 'Page1 Page2 ->Page1<-'.



Now, this isn't normally a problem, but I've noticed that Ionic's Internally stored history is divorced from the browser history. So, if Ionic's history is ever different from the browser's history problems can start happening. For example, if you refresh the page then the browser history stays the same, but Ionic's history becomes a list containing only the current page in it.



E.X.




  1. If we go from Page1 to Page2 to Page3 then refresh
    Browser History: 'Page1 Page2 ->Page3<-'
    Ionic History: '->Page3<-'


  2. Now we go to Page 2 by pressing the browser back button
    Browser History: 'Page1 ->Page2<- Page3'
    Ionic History: 'Page3 ->Page2<-' (Because it didn't find an instance of Page2 before Page3 in its history, it makes a new instance and puts it at the top of the stack instead)


  3. Now we SetRoot("Page3"). Because Ionic History thinks it needs to go back to get to Page3 it will force the browser History to go back as well to try to keep things matched up.
    Browser History: '->Page1<- Page2 Page3'
    Ionic History: '->Page3<- Page2'


  4. Result: Because the url changed due to the browser History now being on Page1, an extra unwanted transition will trigger that will take us to Page1 when we wanted to go too Page3.



Just to make it absolutely clear: The Ionic History I am talking about is something I believe exists due to the behavior of my application. I have never actually seen where it is stored. In addition, I know for sure that the Ionic History is different from the NavCtrl Navigation Stack because my application only uses .SetRoot(), so the Navigation Stack is only ever an array of length 1 containing only the current Page.



With all of that said, here is my question:



Is there a way to access and manipulate the Ionic Framework's internally stored history? At the very least is there a way to wipe it?



Thanks.










share|improve this question






















  • Hmm have you tried the remove method for clearing the NavControllers stack?
    – Phonolog
    Nov 17 '18 at 16:03










  • @Phonolog Since I use SetRoot for all of my page transitions, the NavController's stack only ever has the current page in it.
    – Tywana60
    Nov 18 '18 at 20:22














0












0








0







I've been building an Angular4/Ionic3 application but I've run into a bit of a stumbling block related to browser history and Ionic's history related quirks.



First, a little background info. My application uses navCtrl.SetRoot() for all of its page transitions because .pop() and .push() didn't play well with refreshing the browser page. In the process of development I have made note of a quirk with Ionic navigation: If you go from Page1 to Page2 then try to go Page1 again (using .SetRoot("Page1")) Ionic will look at its history and notice that you were at Page1 just before Page2 so it will decide go backwards in the browser history instead of making a new instance of Page1 in the history. At the end of the .SetRoot("Page1") operation, the history will look like '->Page1<- Page2' rather than 'Page1 Page2 ->Page1<-'.



Now, this isn't normally a problem, but I've noticed that Ionic's Internally stored history is divorced from the browser history. So, if Ionic's history is ever different from the browser's history problems can start happening. For example, if you refresh the page then the browser history stays the same, but Ionic's history becomes a list containing only the current page in it.



E.X.




  1. If we go from Page1 to Page2 to Page3 then refresh
    Browser History: 'Page1 Page2 ->Page3<-'
    Ionic History: '->Page3<-'


  2. Now we go to Page 2 by pressing the browser back button
    Browser History: 'Page1 ->Page2<- Page3'
    Ionic History: 'Page3 ->Page2<-' (Because it didn't find an instance of Page2 before Page3 in its history, it makes a new instance and puts it at the top of the stack instead)


  3. Now we SetRoot("Page3"). Because Ionic History thinks it needs to go back to get to Page3 it will force the browser History to go back as well to try to keep things matched up.
    Browser History: '->Page1<- Page2 Page3'
    Ionic History: '->Page3<- Page2'


  4. Result: Because the url changed due to the browser History now being on Page1, an extra unwanted transition will trigger that will take us to Page1 when we wanted to go too Page3.



Just to make it absolutely clear: The Ionic History I am talking about is something I believe exists due to the behavior of my application. I have never actually seen where it is stored. In addition, I know for sure that the Ionic History is different from the NavCtrl Navigation Stack because my application only uses .SetRoot(), so the Navigation Stack is only ever an array of length 1 containing only the current Page.



With all of that said, here is my question:



Is there a way to access and manipulate the Ionic Framework's internally stored history? At the very least is there a way to wipe it?



Thanks.










share|improve this question













I've been building an Angular4/Ionic3 application but I've run into a bit of a stumbling block related to browser history and Ionic's history related quirks.



First, a little background info. My application uses navCtrl.SetRoot() for all of its page transitions because .pop() and .push() didn't play well with refreshing the browser page. In the process of development I have made note of a quirk with Ionic navigation: If you go from Page1 to Page2 then try to go Page1 again (using .SetRoot("Page1")) Ionic will look at its history and notice that you were at Page1 just before Page2 so it will decide go backwards in the browser history instead of making a new instance of Page1 in the history. At the end of the .SetRoot("Page1") operation, the history will look like '->Page1<- Page2' rather than 'Page1 Page2 ->Page1<-'.



Now, this isn't normally a problem, but I've noticed that Ionic's Internally stored history is divorced from the browser history. So, if Ionic's history is ever different from the browser's history problems can start happening. For example, if you refresh the page then the browser history stays the same, but Ionic's history becomes a list containing only the current page in it.



E.X.




  1. If we go from Page1 to Page2 to Page3 then refresh
    Browser History: 'Page1 Page2 ->Page3<-'
    Ionic History: '->Page3<-'


  2. Now we go to Page 2 by pressing the browser back button
    Browser History: 'Page1 ->Page2<- Page3'
    Ionic History: 'Page3 ->Page2<-' (Because it didn't find an instance of Page2 before Page3 in its history, it makes a new instance and puts it at the top of the stack instead)


  3. Now we SetRoot("Page3"). Because Ionic History thinks it needs to go back to get to Page3 it will force the browser History to go back as well to try to keep things matched up.
    Browser History: '->Page1<- Page2 Page3'
    Ionic History: '->Page3<- Page2'


  4. Result: Because the url changed due to the browser History now being on Page1, an extra unwanted transition will trigger that will take us to Page1 when we wanted to go too Page3.



Just to make it absolutely clear: The Ionic History I am talking about is something I believe exists due to the behavior of my application. I have never actually seen where it is stored. In addition, I know for sure that the Ionic History is different from the NavCtrl Navigation Stack because my application only uses .SetRoot(), so the Navigation Stack is only ever an array of length 1 containing only the current Page.



With all of that said, here is my question:



Is there a way to access and manipulate the Ionic Framework's internally stored history? At the very least is there a way to wipe it?



Thanks.







ionic-framework ionic3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 20:37









Tywana60

1




1












  • Hmm have you tried the remove method for clearing the NavControllers stack?
    – Phonolog
    Nov 17 '18 at 16:03










  • @Phonolog Since I use SetRoot for all of my page transitions, the NavController's stack only ever has the current page in it.
    – Tywana60
    Nov 18 '18 at 20:22


















  • Hmm have you tried the remove method for clearing the NavControllers stack?
    – Phonolog
    Nov 17 '18 at 16:03










  • @Phonolog Since I use SetRoot for all of my page transitions, the NavController's stack only ever has the current page in it.
    – Tywana60
    Nov 18 '18 at 20:22
















Hmm have you tried the remove method for clearing the NavControllers stack?
– Phonolog
Nov 17 '18 at 16:03




Hmm have you tried the remove method for clearing the NavControllers stack?
– Phonolog
Nov 17 '18 at 16:03












@Phonolog Since I use SetRoot for all of my page transitions, the NavController's stack only ever has the current page in it.
– Tywana60
Nov 18 '18 at 20:22




@Phonolog Since I use SetRoot for all of my page transitions, the NavController's stack only ever has the current page in it.
– Tywana60
Nov 18 '18 at 20:22












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345046%2fhow-do-i-manipulate-ionic3s-internal-page-history%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53345046%2fhow-do-i-manipulate-ionic3s-internal-page-history%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?