One way to do this (without manipulating the dom from a controller) is to create a directive, then use angular.element().append() to inject the html response of the POST call.
HTML
<remote-content></remote-content>
The directive will replace that element with the retrieved HTML
Note: this is dash-case to match the camelCase of the directive name, remoteContent -> remote-content
DIRECTIVE
app.directive('remoteContent', function($http) {
return {
restrict: 'E',
link: function(scope, element, attrs) {
$http.post('/endpoint', {format:'html'}).
success(function(html) {
// remove wrapping html and body tags etc if necessary
angular.element(element).append(html);
}).
error(function(data, status, headers, config) {
alert("Could not fetch remote HTML");
});
}
};
});
Here's a Plunkr that shows the DOM HTML injection without the $http.post call.
Since the HTML response is just a string, you can use replace to find the wrapping tags and remove them:
var content_html = html.replace(/<\/?(html|body)>/g, '');
But if the <head>
contains script tags and whatnot, you'll need to use substring to find the <body>
tag and just get the content within it.