AngularJS ngBindHtml with filter.
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.1/angular-sanitize.min.js"></script>
<div ng-app="myApp" ng-controller="MainCtrl">
<div>Here is the extracted data <pre><{{data | extractSrcUrl}}</pre></div>
<div>Below is the filtered data via ng-bind-html</div>
<div ng-bind-html="data | extractSrcUrl"></div>
<div>Below is the original data via ng-bind-html</div>
<div ng-bind-html="data"></div>
</div>
CSS
div > div {
margin: .25rem;
padding: .25rem;
border: 1px solid black;
}
JavaScript
var app = angular.module('myApp', ['ngSanitize']);
app.controller('MainCtrl', function ($scope) {
$scope.data = '<img src="http://o.aolcdn.com/hss/storage/midas/37c38989a5f26031be3e0ec5ffc5cd2/200012386/got-hbo-go-crash-2014-04-07-01_thumbnail.jpg"/> Viewing of the Game of Thrones season debut came to a crashing halt yesterday thanks to server problems with HBO Go. The cable outfit first reported the problem late yesterday via Twitter, and finally restored full service early this morning. That...';
});
app.filter('extractSrcUrl', function () {
return function (text) {
// You could use regex to grab this or...
var output = angular.element(text).attr('src');
return(output);
}
});