I am creating post request with promise, using angular 6. In my service I created a request function which looks like this:
sendRequest() {
let promise = new Promise((resolve, reject)=>{
this.http.post(this.url, this.params, {responseType: 'text'}).toPromise()
.then(res =>{
this.data = res;
this.router.navigateByUrl('1/success'); // I want to show res code on this page
resolve();
},
error => {
this.data = error;
this.router.navigateByUrl('1/fail');
reject(error);
}
)
return promise;
})}
res returns text in html format like that:
<html>
<head>
some code
</head>
<body>
code i need
</body>
</html>
, which is fine, but I would like to use that text as html code on success/fail page. Specifically, everything that is in body tag. How can i achieve that? If i use anything like
<div [innerHTML]="res"></div>
or
{{res}}
it just returns plain text.