Hello guys
First off, I wanted to let you know that I’ve been already trying to figure this out on my own for some time without any success, that’s why I finally decided to look for help here. It’s also important to clarify that I’m quite new to this, I started just this year with web development, so I’m still ignorant on many things and I’m really sorry I’m my terminology is a little off.
That said, I have the following problem: I need some code to be executed every time a page is loaded, and I thought “componentWillLoad” was the right choice for this. However, I can’t really comprehend its behavior. Why does it sometime get triggered and some times it doesnt?
Here’s a video showing what I mean:
https://www.youtube.com/watch?v=orc9eECz2ac
I have a console.log inside of a “componentWillLoad” function in every page, and the following happens:
- The first time I go into “/”, it gets triggered. No problem.
- Then, when I go from “/” to “/dashboard” it gets triggered. No problem
- Then, from “/dashboard” to “/project” it gets triggered. No problem.
- Then, when I go back from “/project” to “/dashboard” it doesn’t get triggered. However, if I go again from “/dashboard” to “/project” it does get triggered every time. Why does this happen?
To switch between pages I use this in every case:
this.navCtrl.push("/url", "forward")
Please let me know if you need more information. In case you need to take a look at the code, it’s here (I’m pretty sure the code is a mess in terms of best practices, so sorry about that). The important parts are in the “component” foldes, specifically in the components “app-login”, “app-project” and “app-dashboard”.
Thanks in advance guys!