Я пытаюсь отобразить HTML-шаблон с помощью innerHTML и строки html + css, которые я получаю из SQL.
Пример строки шаблона:
<html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Template Name</title><style type="text/css"> p{ color:red; }</style> </head> <body> <h1>#headding#</h1> <p style="color:red;">#paragraph#</p><a href="#url#">#urltext#</a> </body> </html>
Теперь он отлично отображает HTML, но похоже, что он удаляет теги стиля и просто отображает текст внутри него.
Пример рендера:
Часть рендеринга HTML:
<div [innerHtml]="templateBody">
</div>
Части сайта Home.component.ts:
@Component({
selector: "home",
templateUrl: `client/modules/home/home.component.html`,
encapsulation: ViewEncapsulation.Emulated
})
export class HomeComponent implements OnInit{
templateBody: string;
.....other code
}
Я пробовал его с инкапсулированием: ViewEncapsulation.Emulated/None и т.д., попробовал встроенный CSS, и я попытался добавить: host → > infront из тега p. Все они делают то же самое.
Любые предложения?