Edu*_*res 3 nativescript angular2-nativescript angular
我正在尝试在 Nativescript + Angular 中播放 ListView,但无法呈现定义的模板。我的 ListView 显示的是 [object Object] 而不是模板。我总是得到那个结果。如果数组中的项是字符串,则文本显示在行上,如果是对象,则坚持不显示我的模板并显示 [对象对象]。
我得到的结果是这样的:
下面是我的代码
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"});
}
}
Run Code Online (Sandbox Code Playgroud)
eventos.component.html
<GridLayout>
<ListView [items]="registros">
<template let-item="item">
<Label [text]="item.tipo"></Label>
</template>
</ListView>
Run Code Online (Sandbox Code Playgroud)
小智 6
我遇到了同样的问题,我通过包含 import { NativeScriptModule } from "nativescript-angular/platform" 来解决它;在包含列表的模块中。
| 归档时间: |
|
| 查看次数: |
1678 次 |
| 最近记录: |