I'm having trouble redirecting my app outside of Angular to the logout page.
I'm doing it by using $window.location.href
but it's not working on FireFox.
So, There was a suggestion to use $window.location
directly but since i'm writing in Typescript i need to create a new Location object rather then just assign my string to it...
I looked into lib.d.ts and i saw that location is declared as:
declare var Location: {
prototype: Location;
new(): Location;
}
so i adjust my code to:
var url: string = "http:\\\\host:port/blabla/logout";
var loc: Location = new Location();
loc.href = url;
this.$window.location = loc;
but got this error:
Error: Illegal constructor.
Any Idea how to create the Location object? Is it a good practice to do so? Any other insights maybe?
Thanks
It actually looks like you're not supposed to build new Location
objects. So I don't think there's a constructor available anywhere for this. Though you can use anchors to build them for you.
If you're trying to set a new location, you can go with setting window.location.href
instead of window.location
(These two are equivalent).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With