Correct way to populate listView with object items?

前端 未结 1 1697
我寻月下人不归
我寻月下人不归 2021-01-23 22:53

In my NativeScript project, I am trying to fill a ListView with instances of a custom object (defined as an interface). But the output (on a android emulator) is quite strange :

相关标签:
1条回答
  • 2021-01-23 23:34

    You need the following syntax when using NativeScript + Angular-2 list-view:

    <ListView [items]="fileItems">
        <template let-myitem="item">
            <StackLayout>
                <Label width="5%" height="5%" text="Type"></Label>
                <Label [text]="myitem.name"></Label>
            </StackLayout>
        </template>
    </ListView>
    

    For better understanding you can reffer to the sample-Groiceries angular-end branch here

    And check the tutorial about NativeScript + Angular-2 ListView here

    0 讨论(0)
提交回复
热议问题