Reputation: 102
My problem is that the german ü, ä, ö in HTML are displayed as not known sign . You can write ü as "ü ;" ä as "ä ;" and so one. But is it not possible to replace ü with "ü ;" in a typescript method. The result will be "ü ;".
This is my method in typescript which replace ü with "ü ;"
public stringHelper(textUml: string): string {
textUml = textUml.replace("ü", "ü");
debugger;
return textUml;
}
<button class="btn btn-success" (click)="addKeySkill()">{{stringHelper("Hinzufügen")}}</button>
Instead of displaying "Hinzufügen" its display "Hinzufü ;gen".
Upvotes: 0
Views: 542
Reputation: 7466
That's because when you use {{ }}
in your HTML template, Angular escapes the string. This is thus expected behaviour that your &
is escaped, and not considered as an HTML entity.
So you should leave it unescaped (with ü
) and it should work fine.
If you still want to put the exact HTML code, and not escape the contents of a variable, you need to define a custom pipe, and then use innerHTML
to output the code.
In your example, once you define the pipe, you would put:
<button class="btn btn-success" (click)="addKeySkill()">
<span [innerHTML]="stringHelper('Hinzufügen') | keepHtml"></span>
</button>
Upvotes: 0
Reputation: 11000
Use Regex instead and apply g
so all occurrences will be replaced (otherwise, only the first "ü" is replaced):
textUml = textUml.replace('/ü/g', "ü");
Upvotes: 1