Search code examples
javascriptangularbrowserangular-router

Is there a way to reload my app without window.location.reload() and ngOnInit()?


Is there any way to reload my Angular 11 app without window.location.reload() and ngOnInit()?

window.location.reload() makes Chrome reload the tab which is not my desired outcome. And ngOnInit() causes some wierd bugs in my app.

I would like to have something similar to window.location.reload() but that doesn't refresh the Chrome tab.

Any solutions to this?

Thanks in advance.


Solution

  • it looks like without any data you approach is wrong, you can use ngAfterViewInit or one of the life cycle hooks with element refresh. however if you are trying to refresh data on the screen you should look at service binding so that the data is "reactive".

    you can use behavior subject or subject binding but it makes your data as a subscribed event so its updated without redrawing the viewport.

    however without any type of code or anything this is only speculation.