Проверьте мое решение вашей проблемы:
<div ng-repeat="output in data">
<p ng-bing-html="getOutputElement(output)"></p>
</div>
getOutputElement
определено ниже:
$scope.getOutputElement = function (output) {
var ele = document.createElement('div');
ele.innerHTML = output;
var imgName = ele.getElementsByTagName('img')[0];
// If img found, then check with an http GET status code comparison with 200
if (imgName) {
var imgValue = imgName.getAttribute("src");
var request = new XMLHttpRequest();
request.open('GET', imgValue, false);
request.send(null);
if (request.status === 200) {
// html string with img ele and url is valid -> return the string
return $sce.trustAsHtml(output);
}
// html string with img ele but img url not valid -> return what you want
// for example you can remove img element and keep other html then return string without img
imgName.remove();
return $sce.trustAsHtml(ele.innerHTML);
}
// html string without img ele
return $sce.trustAsHtml(output);
};