我有这样的 html 模板:
$scope.template = '<span class="pointer"><i class="icon-refresh pointer" ng-click="refresh()"></i></span>';
我想使用绑定这个模板ng-bind-html
,我尝试使用它,也使用过ng-bind-html-unsafe
,但不幸的是它绑定了 html 字符串,没有点击操作。
<span ng-bind-html="template"></span>
<span ng-bind-html-unsafe="template"></span>
我读到类似的问题,它说ng-click
之后加载ng-bind
,那么有人可以向我介绍如何解决这个问题吗?
也许您需要在控制器内编译模板?
angular.controller('ABCDCtrl', function($scope, $compile){
var templateHTML = '<span class="pointer"><i class="icon-refresh pointer" ng-click="refresh()"></i></span>';
$scope.template = $compile(templateHTML)($scope);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)