Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

a term expected error when trying to insert typescript element in the styling

In my ts file I have elements that I use in the html file. In this example I use element.color (value = #3b5998) and element.name (value = Facebook). When putting the values like below the icon one works but the color is not. The code looks like this:

<fa style="color: {{element.color}};" name="{{element.icon}} fa-3x"></fa>

After the color: there is a red line saying, "a term expected". But I don't know what to change. I know it's a dump error but i'm stuck.

Image

like image 420
Kyle Van Raay Avatar asked Sep 06 '25 07:09

Kyle Van Raay


1 Answers

To bind to a style there are two ways:

Using style binding

<fa [style.color]="element.color" [name]="element.icon + ' fa-3x'"></fa>

or by using the NgStyle directive

<fa [ngStyle]="{ color: element.color }" [name]="element.icon + 'fa-3x'"></fa>
like image 135
Poul Kruijt Avatar answered Sep 07 '25 19:09

Poul Kruijt