I have a page with angular-moment on it. Upon page rendering angular-moment is working. Using
<span am-time-ago="message.time"></span>
But when I append new html.. it's not working
var date = '<span am-time-ago=\"message.time\"></span>';
angular.element('#here').append(date);
Did I missed something? Please help...
Thanks, Kurai
HTML that is appended manually must be bound to a
$scope
.To do this you inject and use the
$compile
service.It's often written like this:
Note that if you must add HTML manually like this and want to follow the best practices of Angular, it should be done from a directive.