Javascript 使用am time ago的相对时间不使用ng bind html

Javascript 使用am time ago的相对时间不使用ng bind html,javascript,jquery,html,angularjs,Javascript,Jquery,Html,Angularjs,我试图用angularJS的角度力矩插件来显示相对时间 当我在我的html模板上直接添加下面的代码时,它正在工作并显示正确的相对时间 <span am-time-ago='currentTime' class='item-note' ></span> 但如果我使用ng bind html并尝试使用scope变量显示相对时间,它就不起作用了。这是我使用的代码 //html <div id="{{parameterGuid}}" ng-bind-html="use

我试图用angularJS的角度力矩插件来显示相对时间

当我在我的html模板上直接添加下面的代码时,它正在工作并显示正确的相对时间

<span am-time-ago='currentTime' class='item-note' ></span>

但如果我使用ng bind html并尝试使用scope变量显示相对时间,它就不起作用了。这是我使用的代码

//html
<div id="{{parameterGuid}}" ng-bind-html="userChat">

</div>

//js
$scope.userChat = $sce.trustAsHtml("<div am-time-ago='currentTime' class='item-note'></div>");
//html
//js
$scope.userChat=$sce.trustAsHtml(“”);

根据我的要求,我需要使用ng bing html,因此有人能建议如何在这种情况下显示相对时间吗?

这是因为
ng bind html
$compile
html(从角度上看)。换句话说,Angular不计算HTML中的指令,为什么不能创建一个指令?非常正确@NewDev<代码>元素。使用
$compile
d元素追加
,可以从DirectiveThank。。我将尝试Directive,这是因为
ng bind html
$compile
html(从角度上讲)。换句话说,Angular不计算HTML中的指令,为什么不能创建一个指令?非常正确@NewDev<代码>元素。使用
$compile
d元素追加
,可以从DirectiveThank。。我试试看