I got some data received by an RSS news feed and need to display in in HTML for an ionic framework app. There are two problems. I need to replace '
and amp;
with '
(apostrophe) and blank space.
AngularJS:
$scope.rssItems = [];
var callbackI = 0;
for(var i=0; i<$marketProvider[$scope.currentMarket].rss.length; i+=1){
$webServicesFactory.get($marketProvider[$scope.currentMarket].rss[i], {Accept: "application/xml"}).then(
function success(xmlData) {
console.log("Home News: ", x2js.xml_str2json(xmlData));
if (x2js.xml_str2json(xmlData) == null)
$ionicLoading.hide();
$scope.rssItems = $scope.rssItems.concat(x2js.xml_str2json(xmlData).rss.channel.item);
// $scope.rssItems = $scope.rssItems.replace("amp;","");
callbackI+=1;
if(callbackI == $marketProvider[$scope.currentMarket].rss.length){
//console.info($scope.rssItems);
$ionicLoading.hide();
}
},
function error(error) {
$ionicLoading.hide();
}
);
and html
<div class="list">
<h5 class="item item-positive item-divider" align="justify">Today's Headlines</h5>
<span ng-if="rssItems.length==0">No news available.</span>
<div class="item item-thumbnail-left" ng-bind-html="rssItems(item)" ng-repeat="item in rssItems | orderBy: -dateOrder" ng-click="openNews(item.link)">
<img ng-src="{{item.enclosure._url || item.enclosure[0]._url || item.content._url || item.thumbnail._url || 'img/icon.png'}}">
<h2>{{item.title.replace("amp;","") | htmlToPlaintext}}</h2>
<p>{{item.pubDate | shortDate}}
<p>{{item.description | htmlToPlaintext}}</p>
</div>
<h2>{{item.title.replace("amp;","") | htmlToPlaintext}}</h2>
able to replace correctly but<h2>{{item.title.replace("'","'") | htmlToPlaintext}}</h2>
unable to replace with aprotrophe.- I need to replace both at once.