
另一种办法就是使用动态数据咯,如<div data-key="{parameterName}">,当parameterName的值改变时data-key属性自动就更新了,例$scope.parameterName='new value'
用{{}}是一定没法输出html的
不知道你项目里是怎么限制的不能使用 ng-bind-html
那你试试自己写个指令来实现一下好了
var app = angular.model('app' , [])app.directive('stringHtml' , function(){
return function(scope , el , attr){
if(attr.stringHtml){
scope.$watch(attr.stringHtml , function(html){
el.html(html || '')//更新html内容
})
}
}
})
app.controller('TestCtrl' , function($scope){
$scope.string = '<button type="button">测试html按钮</button>'
})
html:
<div ng-controller="TestCtrl"><span string-html="string"></span>
</div>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)