Enable Videos in ng-bind-html


#1

Hi everybody,

I post because I have a small problem with an application that I develop. Indeed, this application has the goal of grouping articles written in html, and some contain youtube or dailymotion videos in the form of embed. I use the ng-bind-html = “article.content” attribute to retrieve the article’s content, but videos do not appear in it.

To try to remedy this I use the ngSanitize package via a filter I’ve created, as well as another filter to make the URLs clickable in the application (according to attributes on the links in the html content).

The links work fine, but the videos are still not showing and I have no error = /

angular.module('app', ['ionic', 'ionic.cloud', 'satellizer', 'permission', 'ngMessages', 'fusionMessages', 'chart.js', 'ngCordova', 'ngSanitize'])
.filter('sanitizer', ['$sce', function($sce) {
    return function(content) {
      return $sce.trustAsHtml(content);
    };
  }])
  .filter('clicker', ['$state', function($state) {
    return function(content) {
      
      $('#clicker-content, #article-content').on('click', 'a', function(e) {
        e.preventDefault();
        if( typeof $(this).attr('ui-sref') != 'undefined' ) {
          
          var id = $(this).attr('data-id');
          var route = $(this).attr('data-route');
          var param = $(this).attr('data-param');
          
          if( typeof route != 'undefined' && typeof param != 'undefined' && typeof id != 'undefined' ) {
            var routeParams = {};
            routeParams[param] = id;
  
            $state.go(route, routeParams);
            
          } else {
            $state.go($(this).attr('ui-sref'));
          }
        } else {
           window.open($(this).attr('href'), '_system', 'location=yes');
        }
      });
  
      return content;
    }
  }])

And this is how i work in my article body :

<p class="article-content" id="article-content" ng-bind-html="article.content | clicker | sanitizer"></p>

If someone has ever had this scenario, or has an idea on how to solve the problem, I am taker =)