[英]How to display unicode from Typescript into Html with Angular
i´m using angular 5 and i want to display a string from a typescript file, which contains unicode into the html file. 我正在使用angular 5,我想显示一个打字稿文件中的字符串,该文件包含html文件中的unicode。
example.component.ts example.component.ts
adDummy: AdDataDummy[] = [
{
name: "hanz",
domain: "test.de",
adPath: "CN=hanz,OU=Anwender,OU=Kunz,OU=test,DC=de",
icon: "user.ico"
},
{
name: "Hanz2",
domain: "ok.de",
adPath: "CN=Hanz2,OU=Anwender,OU=Köln,OU=ok,DC=de",
icon: "user.ico"
}];
example.component.html example.component.html
<div class="col">
<h4 >User {{ currentAdItem.name }} (Logon name: {{ currentAdItem.adPath }})</h4>
<div>
Current printer connections
</div>
</div>
Outcome: 结果:
User Hanz (Logon name: CN=Hanz,OU=Anwender,OU=K�ln,OU=K-is,DC=de)
K ln should be Köln 科隆应为科隆
Your example worked in stackblitz. 您的示例在stackblitz中工作。 But you can try use [innerHTML] attribute.
但是您可以尝试使用[innerHTML]属性。 Here example in stackblitz.
这是stackblitz中的示例。
example.html example.html
<div class="col" *ngFor="let currentAdItem of adDummy">
<h4 [innerHTML]="concateItem(currentAdItem)"></h4>
<div>
Current printer connections
</div>
</div>
example.ts example.ts
adDummy = [
{
name: "hanz",
domain: "test.de",
adPath: "CN=hanz,OU=Anwender,OU=Simmern,OU=test,DC=de",
icon: "user.ico"
},
{
name: "Hanz2",
domain: "ok.de",
adPath: "CN=Hanz2,OU=Anwender,OU=Köln,OU=ok,DC=de",
icon: "user.ico"
}];
concateItem(currentAdItem: any) {
return `User ${currentAdItem.name} (Logon name: ${currentAdItem.adPath})`
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.