Dynamic html based on properties / data



Im new to ionic v1, The goal is I’m creating a dynamic html page based on the data provided by a json data but the problem is the ng-repeat is not rendering the images upon using the ng-bind-html.

Any suggestions on how to fix the problem?. The overall goal is I need to create a page with a category section (based on the data provided so it can be multiple) and a scrollable banner images inside.


.factory('HTMLManager', function () {
  return {
    vdeoPage: function ( ) {
        var htmlTemplate='<div class=\"item item-divider vdeo-header\"><h3>{CATEGORY}</h3></div><a class=\"item item-list-detail vdeo-table\"><ion-scroll direction=\"x\"><img ng-repeat="image in allImages" ng-src="{{image.src}}" ng-click="showImages($index)" class="image-list-thumb"/></ion-scroll></a><br/>';                            
        return htmlTemplate;


.controller('MediaCtrl', function($state, $scope, $ionicModal, VideoManager, HTMLManager, $sce) {

$scope.allImages = [{
        'src' : 'img/take1.png', 'category':'NEW', 'vdeo' : 'video/test1.mp4', 'title' : 'Test Title', 'synopsis_title' : 'Synop', 'synopsis' : 'Test synopsis', 'thumbnail' : 'img/test1.png',
    }, {
        'src' : 'img/trip1.png', 'category':'LATEST','vdeo' : 'video/test2.mp4', 'title' : 'Test Title 2', 'synopsis_title' : 'Synop2', 'synopsis' : 'Test synopsis2', 'thumbnail' : 'img/test2.png',

    $scope.vdeoHTML = $sce.trustAsHtml(HTMLManager.vdeoPage());


            <div ng-bind-html="vdeoHTML"></div>


you have to insert ngSanitize as a dependency in app.js . for reference see the angular docs https://docs.angularjs.org/api/ng/directive/ngBindHtml



The ngSanitize is already set on my app.js

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngCordova', 'ngSanitize'])


it should work… can you share the code on codepen so i can debug