# Create Dynamic View

**URL:** <https://forum.ionicframework.com/t/create-dynamic-view/94156>\
**Category:** ionic-v1\
**Created:** [June 13, 2017, 3:44pm UTC](https://forum.ionicframework.com/t/create-dynamic-view/94156 "2017-06-13T15:44:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bassetti\_creator](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@bassetti\_creator](https://forum.ionicframework.com/u/bassetti_creator)\
**Post date:** [June 13, 2017, 3:44pm UTC](https://forum.ionicframework.com/t/create-dynamic-view/94156/1 "2017-06-13T15:44:15Z")

</div>

Hi, I want to build an app which only works with Json Config File.  
So, I want to create some button with specific link, but in HTML, not in javascript. (I create element in JS but I print the outerHTML)

But when I put personnal link, the sanitizer (or I don’t know) reset my link, look at code :

My state :

```auto
.state('menu.samplesToOrder', {
      url: '/samplesToOrder/{config}',
      views: {
        'side-menu21': {
          templateUrl: 'templates/samplesToOrder.html',
          controller: 'samplesToOrderCtrl'
        }
      }
    })

```

My link generator in my button : (item is the json config parsed)

```auto
  button.setAttribute("href", "#/side-menu/" + item.module + "/" + item.config + "/");
  button.setAttribute("ui-sref", "menu." + item.module + "()");

```

My HTML View :

```auto
<div compile="content" class="htmlComment"></div>

```

My Compile Directive (from SOF) :

```auto
  .directive('compile', ['$compile', function ($compile) {
  return function(scope, element, attrs) {
    scope.$watch(
      function(scope) {
        // watch the 'compile' expression for changes
        return scope.$eval(attrs.compile);
      },
      function(value) {
        // when the 'compile' expression changes
        // assign it into the current DOM
        element.html(value);

        // compile the new DOM and link it to the current
        // scope.
        // NOTE: we only compile .childNodes so that
        // we don't get into infinite loop compiling ourselves
        $compile(element.contents())(scope);
      }
    );
  };
}])

```

My Controller (HTML Injection) :

```auto
.controller('homeCtrl', ['$scope', '$stateParams', '$sce', 'configFactory',
    function ($scope, $stateParams, $sce, configFactory) {
      configFactory.getConfig("default")
        .then(function (response) {
          debugger;
          var config = response.data;
          var html = createView(config);
          $scope.content = $sce.trustAsHtml(html);

        });
    }])

```

I want to create link like `href="#/side-menu/samplesToOrder/ConfigFileName"` but always my HTML delete my href and replace it by `href="#/side-menu/samplesToOrder/"`

Can you help me ? thank you.

I also tried that (disable sanitization and enable whitelist URL) :

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/0/9/09f83c9291843b38336c68aa7c40871b32d5e9ad.png)
