Ionic 5 reload page

I have an ionic single page web app in which the user completes some information and create some components dynamically (new columns, cards, etc). After clicking on a button I want to fully reload my page in the initial state. I have tried angular lifecycle hooks but it doesn’t seem to trigger them because there is no change in the route. I tried also route.navigate(['home']) , but it doesn’t work. I don’t need to save any data. Just reload everything.

“Fully reload my page” isn’t really a natural concept in a reactive webapp. I absolutely understand that when you’re thinking in an imperative mindset, it seems a natural thing to do, but eventually I at least personally ran into a huge wall when trying to write Ionic apps imperatively.

Your description is pretty vague, so I can’t say much more in a concrete fashion, but ordinarily you have a situation like this:

interface ThingThatIsDisplayedAsAColumn { ... }
interface ThingThatIsDisplayedAsACard { ... }
class Page {
  columns: ThingThatIsDisplayedAsAColumn[] = [];
  cards: ThingThatIsDisplayedAsACard[] = [];
  
  addColumn(c: ThingThatIsDisplayedAsAColumn): void {
    this.columns.push(c);
  }

  addCard(c: ThingThatIsDisplayedAsACard): void {
    this.cards.push(c);
  }
}
<column *ngFor="let col of columns">...</column>
<card *ngFor="let card of cards">...</card>

So our template is designed to respond to changes in the backing properties that exist in the page controller. In this situation, ordinarily what people would mean by “fully reload my page in the initial state” just looks like this:

reset(): void {
  this.columns = [];
  this.cards = [];
}

…and Angular’s change detection takes care of the rest.

I was trying something like forcing an angular lifecycle hook to do the job but as far as i see your answer is the only way. I was searching for something like

window.location.reload()

This is a perfect example of what I mean by an imperative mindset. Imperative programs tell the computer “do this, then do that, then go over there and set this to that and come back here”. I absolutely get where you are coming from mentally. The problem is that you just can’t write imperative webapps, because the user determines the flow of control of the program, and your code reacts to that.

You can try (I did, for months), but eventually I tired of fighting the framework and learned to embrace reactive and functional style when doing webapps. I hope you can join that party as well.