Sergino
Sergino

Reputation: 10838

NativeScript error. More than one view found in list template

I had such ListView

<ListView [items]="groceryList" row="1" class="small-spacing" [class.visible]="listLoaded">
    <template let-item="item" columns="*, auto" >
      <Label [text]="item.name" class="medium-spacing"></Label>      
    </template>
  </ListView>

I want to add image button. So I just added columns="*, auto" to template and col="0" to Label and col="1" to my Image

 <ListView [items]="groceryList" row="1" class="small-spacing" [class.visible]="listLoaded">
    <template let-item="item" columns="*, auto" >
      <Label [text]="item.name" class="medium-spacing" col="0"></Label>
      <Image src="res://delete" (tap)="delete(item.id)" col="1"></Image>      
    </template>
  </ListView>

After running an emulator I am getting an error:

enter image description here

Any thoughts why is that happening and how to fix that?

Upvotes: 3

Views: 1546

Answers (1)

Manijak
Manijak

Reputation: 732

Only one element allowed innside <template>, you have two. Add a single GridLayout innside the <template> instead, then add you elements there.

Upvotes: 12

Related Questions