我已经编写了下面的代码来在Angular Material对话框中显示一些内容。当我将纯文本添加到textContent时,它可以正常工作。但是当我添加HTML时,它会将HTML显示为文本。如何将HTML绑定到textContent?
这个可以正常工作
<a href="#" ng-click="$scope.Modal()">Sample Link</a>
$scope.Modal = function () {
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('body')))
.clickOutsideToClose(true)
.textContent('sample text')
.ok('Ok')
);
}
这个不起作用
<a href="#" ng-click="$scope.Modal()">Sample Link</a>
$scope.Modal = function () {
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('body')))
.clickOutsideToClose(true)
.textContent('<div class="test"><p>Sample text</p></div>')
.ok('Ok')
);
}
感谢您提前的帮助。