我有一个模态ui(角度引导程序),popupService调用,我想将一个html代码传递给我的popupService.open方法。 结果不是我所期望的,只有一些值是html格式化但我的按钮不会渲染......
<b>hello</b> <button class="btn btn-green" ng-click="$close(null)">Close</button>
应该是绿色但我只有文字......
我的代码:
popupService.js
appServices.service('popupService', [ '$modal','$sanitize',
function($modal, $sanitize, $scope) {
this.open = function(title, message, size, footer){
$modal.open({
templateUrl: 'view/component/popup.html',
size: size,
scope : $scope,
transclude : true,
controller : function($scope){
$scope.title = title;
$scope.templatemessage = message;
$scope.templatefooter = footer;
}
});
}
}
]);
popup.html
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="$close(null)">×</button>
<h3 class="modal-title">{{title}}</h3>
</div>
<div class="modal-body" modal-transclude ng-bind-html="templatemessage">
</div>
<div class="modal-footer" ng-bind-html="templatefooter">
<div ng-include="view/partial/test.html"></div>
</div>
我的app控制器中的app.js
$scope.$watch('error', function() {
//check the error value for load the message by code in current language
console.log('error : '+ $scope.error);
if($scope.error != null && $scope.error > 0){
//display error in popup
$scope.errorMessage = errorService.GetMessageByCode($scope.error);
popupService.open($scope.Translate.error, $scope.errorMessage, 'sm', '<b>hello</b> <button class="btn btn-green" ng-click="$close(null)">Close</button>')
$scope.error = null;
}
});
如何解决这个问题?