I'm currently trying to style the first word of a string inside my Angular ngFor loop. Somehow the class get's applied but not the style inside my CSS file. Also inline styling don't works - why?
This is my CSS I want to apply:
#page-image-title-table .first-entry-word {
font-weight: 500;
}
This is my function to wrap my first word into an element with my class above:
formatTableEntry(tableEntry: string): string {
const tableEntryParts = tableEntry.split(' ');
const firstWord = tableEntryParts[0];
tableEntryParts.shift();
const restOfString = tableEntryParts.join(' ');
return `<span class="first-entry-word">${firstWord}</span> ${restOfString}`;
}
And this is my HTML with my loop:
<div id="page-image-title-table">
<div class="page-image-title-table-row" *ngFor="let tableEntry of tableEntries">
<span [innerHTML]="formatTableEntry(tableEntry)"></span>
</div>
</div>
You can see my working example here: