New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is proper way to reload page with AngularJs 2 and TypeScript? #7076

Closed
newsash opened this Issue Feb 14, 2016 · 18 comments

Comments

Projects
None yet
@newsash

newsash commented Feb 14, 2016

$window.location.reload(); from previous version.

@zoechi

This comment has been minimized.

Contributor

zoechi commented Feb 15, 2016

I think I have seen
constructor(private location:Location) {} 
... 
this.location.reload();

but not tried myself.

GitHub issues are for bugs and feature requests. Please use channels like StackOverflow, Gitter, Google groups,... for support questions.

@vactorlao

This comment has been minimized.

vactorlao commented Feb 20, 2016

location.reload();
that work for me

@zoechi

This comment has been minimized.

Contributor

zoechi commented Apr 3, 2016

@vactorlao Location doesn't have a reload() method. I don't know where I got this from when I posted my above comment. Curious how it could work for you...

@csmrkid

This comment has been minimized.

csmrkid commented Apr 9, 2016

@zoechi the "location" is the window.location not ng's location. You may use window.location.reload() or location.reload();

@nirmalauwucst

This comment has been minimized.

nirmalauwucst commented Feb 23, 2017

thanks

@villanuevadani

This comment has been minimized.

villanuevadani commented Jun 15, 2017

Is there any ng-universal-friendly method for this???

@elijahbalo

This comment has been minimized.

elijahbalo commented Jul 3, 2017

thanks

@israellev

This comment has been minimized.

israellev commented Dec 3, 2017

this is work for me:

import { Location } from '@angular/common';
constructor(private location: Location) {}
ngOnInit() { load() }
load() {
location.reload()
}

although in the bacillary need to write - this.location.reload();

@rajnishcoder

This comment has been minimized.

rajnishcoder commented Feb 12, 2018

@israellev Property 'reload' does not exist on type 'Location'. In your code this is Javascript code location.reload() so importing location and inject in constructor is waste 👎

@udoyen

This comment has been minimized.

udoyen commented Mar 10, 2018

@predragstevanovic please where will this be added?

@haimleibman

This comment has been minimized.

haimleibman commented Mar 18, 2018

https://stackoverflow.com/a/46219649

  1. Add one more route to same component and navigate to.
  2. Or navigate to same route with any params
@parthkharecha

This comment has been minimized.

parthkharecha commented Apr 16, 2018

this.ngOnInit();
work for me Same route reload.

@sksandeep087

This comment has been minimized.

sksandeep087 commented Apr 17, 2018

how can use this code
this.ngOnInit();
work for me Same route reload.

@parthkharecha

This comment has been minimized.

parthkharecha commented Apr 17, 2018

In my case i have call resolve + set paramquery for url when all list line check and complete then redirect to other route
Otherwise call same route for call resolve and peremquery get in ngOnInit method.
Hope you are understand.

@parthkharecha

This comment has been minimized.

parthkharecha commented Apr 17, 2018

Methods (){
this.ngOnInit();
}

@parthkharecha

This comment has been minimized.

parthkharecha commented Jun 6, 2018

@zoechi other better way #7076 (comment)

@shinoybabu

This comment has been minimized.

shinoybabu commented Jul 21, 2018

DeleteEmployee(id:number)
{
this.employeeService.deleteEmployee(id)
.subscribe(
(data) =>{
console.log(data);
this.ngOnInit();
}),
err => {
console.log("Error occured while deleting the data.");
}
}

@kaziupir

This comment has been minimized.

kaziupir commented Sep 11, 2018

@parthkharecha
It reloads only one component (one where you call onInit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment