0

How to force to refresh the page after redirecting one page to another page. When I try to use location.reload inside ngOnInit(). Page keeps refreshing.

the issue was created item is not updating in the DOM/Model until I refresh the page.

Any expert advice please.

Sample code link

Angular 5 page reload data refresh not working

5
  • Add hash to the end of the url... In ngOnInit, only reload if there is no hash at the end... check: stackoverflow.com/questions/6985507/… Commented Jan 31, 2019 at 10:17
  • Why would you reload? Commented Jan 31, 2019 at 10:21
  • data is not updating... Commented Jan 31, 2019 at 10:23
  • in that case debug why it's not updating. refreshing the page is a bad solution. use console.log to check if the data is loaded and check your template bindings. Commented Jan 31, 2019 at 10:51
  • Issue not reproducible in local. Only on production it occurs. Commented Jan 31, 2019 at 11:33

1 Answer 1

2

When you reload the page Angular application is reloaded as well, your component is initialized, ngOnInit() method runs, you refresh the page and this process starts again. It's not Angular-way to reload the page, you should perform all stuff without reloading.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.