0
我想建立以下指令的简单模式窗口谁的用法是如下:编译HTML在角JS指令
<modal content="<div class='error-text'>this is the content</div>"></modal>
哪些应该生成以下标记:
<div class="modal-wrap fade-hide fade-show" ng-show="showModal" ng-click="showModal=false">
<div class="modal-info clearfix" ng-click="$event.stopPropagation()">
<div class='error-text'>this is the content</div>
<button class="btn form-control" ng-click="showModal=false">OK</button>
</div>
</div>
这是我的指令到目前为止:
.directive('modal', function($compile){
return {
restrict: 'AE',
replace: true,
link: function(scope, element, attrs) {
scope.content = attrs.content;
},
template: '<div class="modal-wrap fade-hide fade-show" ng-show="showModal" ng-click="showModal=false"><div class="modal-info clearfix" ng-click="$event.stopPropagation()">{{content}}<button class="btn form-control" ng-click="showModal=false">OK</button></div></div>',
};
})
我遇到的问题是t没有编译{{content}}。它被呈现为文字html。
如何配置我的指令,使得content
属性被编译为HTML?