为什么在编译包含指令的 html 文本(来自数据库)时出现无限摘要错误

Why infinite digest error while compiling html text (from db) which contains a directive

虽然你不这样做

$('#htmlContent').html(htmlText)
$compile($('#htmlContent'))($scope)

将执行的函数放在 angular 指令上通常会影响摘要循环。我会尝试将渲染的输出放在不同的变量上并将其添加到 ng-bind html,例如

$scope.renderedOutput = $scope.render();
<div id='htmlContent' ng-bind-html='renderedOutput'></div>