Reputation: 8068
I am working on angular4, trying to load a html template into the page.
this.http.get("/assets/abc.html")
.subscribe(
(data) => {
console.log("--------------"+data);
}
);
The result of the http returns me not the html content but only the page path shown as below
--------------Response with status: 200 OK for URL: http://localhost:4200/assets/abc2.html
how to get the real content?
Upvotes: 0
Views: 68
Reputation: 3671
What you get there in the subscription is Response object. To get the actual data, try this:
this.http.get("/assets/abc.html")
.subscribe(
(response) => {
console.log(response.text());
}
);
Upvotes: 2
Reputation: 26370
Extract the content of the response with :
this.http.get("/assets/abc.html")
.subscribe( res => {
console.log(res.text());
}
);
Upvotes: 3