I'm currently attempting to customize the initial word of a string within my Angular ngFor loop. Strangely, the class gets applied but the style defined in my CSS file is not. Inline styling also does not seem to work - any ideas why?
This is the CSS I am trying to implement:
#page-image-title-table .first-entry-word {
font-weight: 500;
}
Here is the function I am using to wrap the first word in an element with the aforementioned class:
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 the HTML code with my ngFor 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 view my demonstration here: