I'm trying to play a ListView in Nativescript + Angular and I can not render the defined template. My ListView is showing [object Object] instead of the template. I always get that result. If the items in my array are a String, the text is displayed on the line, if it is an object it insists on not showing my template and displaying [object Object].
The result I get is this:
Below is my code
eventos.component.ts
import {Component, OnInit, ChangeDetectionStrategy, Input} from '@angular/core';
@Component({
selector: "PrincipalEventosListView",
templateUrl: "pages/principal/eventos/eventos.component.html",
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PrincipalEventosComponent {
public registros: Array<any>;
constructor() {
this.registros = [];
this.registros.push({tipo: "Teste 1"});
this.registros.push("String no lugar de objeto.");
this.registros.push({tipo: "Teste 3"});
this.registros.push(123);
this.registros.push({tipo: "Teste 4"});
}
}
eventos.component.html
<GridLayout>
<ListView [items]="registros">
<template let-item="item">
<Label [text]="item.tipo"></Label>
</template>
</ListView>
