1

I have the following app:

$scope.things = [{
    title: 'my title #1', html: '<input type="text" ng-model="name" />
}, {
    title: 'my title #2', html: '<input type="text" ng-model="name" />
}] 

And on my HTML:

<div class="block" ng-repeat="t in things track by $index">
  <h2>{{t.title}}</h2>
  <div class="html" ng-bind-html="t.html | unsafe"></div>
</div>

Where I bind my HTML using the unsafe filter:

angular.module('app').filter('unsafe', function($sce) { return $sce.trustAsHtml; });

The problem I have its that ng-model="name" its not working, if I bind the model to a view nothing happends, its not showing.

Can someone explain me how to 'compile' the t.html in order to make use of the ng-model?

Hiero
  • 2,182
  • 7
  • 28
  • 47
  • 1
    I think you would need to create a directive and then compile the html and append it to the element in order for this to have any possibility of working. – ewahner Oct 06 '15 at 12:09
  • Answer here http://stackoverflow.com/questions/18157305/angularjs-compiling-dynamic-html-strings-from-database – Hiero Oct 06 '15 at 12:18

0 Answers0