İç HTML'yi ve HTML'den aldığım bir html + css dizesini kullanarak bir HTML şablonu oluşturmaya çalışıyorum.angular2 kullanarak innerHtml için CSS Oluşturma
Şablon dize örneği:
<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>
Şimdi HTML cezası vermektedir ama stil etiketleri düşer ve sadece bunun içindeki metni kılan gibi görünüyor.
HTML işlemek parçası: render
Örnek
<div [innerHtml]="templateBody">
</div>
Home.component.ts parçalar:
@Component({
selector: "home",
templateUrl: `client/modules/home/home.component.html`,
encapsulation: ViewEncapsulation.Emulated
})
export class HomeComponent implements OnInit{
templateBody: string;
.....other code
}
Ben kapsülleme ile denedim: ViewEncapsulation .Emulated/None vs, satır içi CSS denedim ve ekledim: host >>> p etiketinin önündedir. Hepsi aynı şeyi yapıyor.
Herhangi bir öneriniz var mı?
sayesinde onun mükemmel çalışıyor. –
Hoş Geldiniz @ShaunGroenewald – micronyks