В Angular 1.x мы можем вставлять HTML в режиме реального времени с помощью HTML-тега ng-bind-html
в сочетании с вызовом JavaScript $sce.trustAsHTML()
. Это нашло 80% пути, но не работает, когда используются теги Angular, например, если вы вставили HTML, который использовал ng-repeat
или настраиваемые директивы.
Чтобы это сработало, мы могли бы использовать настраиваемую директиву, которая называется $compile.
Что эквивалентно для всего этого в Angular 2? Мы можем привязываться с помощью [inner-html]
, но это работает только для очень простых тегов HTML, таких как <b>
. Он не преобразует настраиваемые Angular 2 директивы в функционирующие элементы HTML. (Скорее как Angular 1.x без шага $compile
.) Что эквивалентно $compile
для Angular 2?