Angular JS bind-html with directive

时间:2015-10-06 12:02:15

标签: javascript angularjs

我有以下应用:

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

在我的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>

我使用不安全的过滤器绑定我的HTML:

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

我遇到的问题是ng-model =“name”它不起作用,如果我将模型绑定到视图没有任何事情发生,它没有显示。

有人可以解释一下如何“编译”t.html以便使用ng-model吗?

0 个答案:

没有答案