Why constructor Called twice when refreshing the page?

In component when we set the root page it will load twice. why its happening?

app.component.ts ------>

if (condition) {
rootpage = "Homepage";
rootpage = "LoginPage";

if the condition true the homepage will be set as root page when the first attempt it will load one time but, when we refreshing the page it will be load twice

how to prevent this ?
help me!


Have you got any solution for this.