Issue
i'm unable to open a link using window.open whithin a http request. Here is how i tried:
const config = {
headers: {token: this.apiKey, authtoken: token},
};
const url = `https://api.eatsmartapp.de/delivery/users/receipt?id=${this.orderId}`;
// @ts-ignore
this.http.get<any>(url, config).subscribe(dataset => {
window.open('link', '_blank');
}, error => {
});
If i try to open the link outside the subscription area its working fine but if i try to open it in my subscription, nothing is happening on my mobile device
Solution
Try using window
as a service. In your module.ts file
providers: [
{ provide: Window, useValue: window }
]
Then in your component.ts, or wherever
constructor(private window: Window) {
// ...
}
in which case your window.open would be like
this.http.get<any>(url, config).subscribe(dataset => {
this.window.open(dataset.url, '_blank');
}
Answered By - Kinglish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.