I got the raw html from my server and then pass it to a ng-bind-html to render. I’m wondering if there is any plugin to parse the html. For example, I want to get all img elements from my html. Any suggestion? Thanks.
I solved this after some googling…
Example: controller of page that contain html codes.
.controller( 'CommentsCtrl', function( $scope, $ionicLoading, $state, $sce, $api ) {
$scope.bindHTML = $sce.trustAsHtml;
You should add $sce
. After define $scope.bindHTML = $sce.trustAsHtml;
like above.
<ion-item ng-repeat="comment in comments">
<div ng-bind-html="bindHTML(comment.text)"></div>
After this you can see HTML codes as html.
Thanks for your reply. But I’m wondering if there are some ionic components to parse the html so that I can for example get an array of all img.?
Sorry, I don’t know. But I think you can do with DOM. ( I never used in Angular before )