Nativescript-angular: Using font-awesome dynamically, icons don't appear

Created on 26 Oct 2017  Â·  2Comments  Â·  Source: NativeScript/nativescript-angular

When I pass font-awesome unicode dinamically, Nativescript don’t show the icon.

my-section.component.ts file:

public items = [
{
title : "Calendar",
icon: ""
},
{
title : "Map",
icon: "",
}
....
];

my-section.component.html file:

<StackLayout orientation="vertical">
    <ListView [items]="items">
        <ng-template let-item="item">
            <Label [text]="item.icon" class="font-awesome"></Label>
        </ng-template>
    </ListView>
</StackLayout>

WRONG RESULT:
temp

If I try hardcoding the unicode value:

<StackLayout orientation="vertical">
    <ListView [items]="sections">
        <ng-template let-item="item">
            <Label text="&#xf0a1;" class="font-awesome"></Label>
        </ng-template>
    </ListView>
</StackLayout>

… the result is correct:

temp-2

Most helpful comment

@ParVisual create a string from char value for code behind as shown in the documentation article here
For example

String.fromCharCode(0xe903).

Let me know if this has resolved the issue.

All 2 comments

@ParVisual create a string from char value for code behind as shown in the documentation article here
For example

String.fromCharCode(0xe903).

Let me know if this has resolved the issue.

Thank you @NickIliev, that solved the problem.

My array provider now look like this:

public items = [
{
title : "Calendar",
icon: String.fromCharCode(0xf073)
},
{
title : "Map",
icon: String.fromCharCode(0xf041),
}
....
];
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sunpasup picture sunpasup  Â·  3Comments

igorls picture igorls  Â·  3Comments

EricRobertBrewer picture EricRobertBrewer  Â·  3Comments

vakrilov picture vakrilov  Â·  3Comments

Sulman633 picture Sulman633  Â·  3Comments