Обзор
Я хочу создать ниже данных в nativescript
![enter image description here](https://i.stack.imgur.com/tKQsN.png)
после некоторых поисков в интернетеЯ обнаружил, что это можно сделать с помощью RadListView
.Поэтому я нахожу из Playground и ListView / Getting-Start
Проблема
Проблема, с которой я сталкиваюсьпрямо сейчас моя RadListView
не связана с данными.
оснастка инструментов разработчика:
![enter image description here](https://i.stack.imgur.com/p3m6p.png)
оснастка консоли:
![enter image description here](https://i.stack.imgur.com/ZnyWK.png)
вывод:
![enter image description here](https://i.stack.imgur.com/TqHSy.gif)
Что я пробовал
home.component.html
Попробовал этот код:
<page xmlns:lv="nativescript-ui-listview">
<ActionBar class="action-bar">
<NavigationButton ios:visibility="collapsed" icon="res://menu" (tap)="onDrawerButtonTap()"></NavigationButton>
<ActionItem icon="res://navigation/menu" android:visibility="collapsed" (tap)="onDrawerButtonTap()"
ios.position="left">
</ActionItem>
<Label class="action-bar-title" text="Home"></Label>
</ActionBar>
<lv:RadListView [items]="inbox">
<ng-template tkListItemTemplate let-item="item" let-i="index">
<StackLayout orientation="horizontal">
<Label fontSize="20" [text]="item._Transactions" />
<Label fontSize="14" [text]="item._PendingYourAction" />
<Label fontSize="14" [text]="item._PendingNextLevelAction" />
<Label fontSize="14" [text]="item._CompletedTransactions" />
</StackLayout>
</ng-template>
</lv:RadListView>
Попробовал этот код:
<lv:RadListView [items]="inbox">
<lv:RadListView.itemTemplate>
<StackLayout orientation="horizontal">
<Label fontSize="20" [text]="inbox._Transactions" />
<Label fontSize="14" [text]="inbox._PendingYourAction" />
<Label fontSize="14" [text]="inbox._PendingNextLevelAction" />
<Label fontSize="14" [text]="inbox._CompletedTransactions" />
</StackLayout>
</lv:RadListView.itemTemplate>
</lv:RadListView>
home.component.ts
import { Component, OnInit } from "@angular/core";
import { RadSideDrawer } from "nativescript-ui-sidedrawer";
import * as app from "tns-core-modules/application";
import { ObservableArray } from "tns-core-modules/data/observable-array/observable-array";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html"
})
export class HomeComponent implements OnInit {
inbox: ObservableArray<Inbox>;
constructor() {
const sideDrawer = <RadSideDrawer>app.getRootView();
sideDrawer.gesturesEnabled = true;
}
ngOnInit(): void {
this.inbox = new ObservableArray<Inbox>();
this.inbox.push(new Inbox("Purchase Request",0,0,"View"));
this.inbox.push(new Inbox("Purchase Order",0,0,"View"));
this.inbox.push(new Inbox("Receipt",0,0,"View"));
this.inbox.push(new Inbox("Payment Advice",0,0,"View"));
console.log(this.inbox);
}
onDrawerButtonTap(): void {
const sideDrawer = <RadSideDrawer>app.getRootView();
sideDrawer.showDrawer();
}
}
export class Inbox {
public _Transactions: string;
public _PendingYourAction: number;
public _PendingNextLevelAction: number;
public _CompletedTransactions: string;
constructor(Transactions: string, PendingYourAction: number, PendingNextLevelAction: number, CompletedTransactions: string) {
this._Transactions = Transactions;
this._PendingYourAction = PendingYourAction;
this._PendingNextLevelAction = PendingNextLevelAction;
this._CompletedTransactions = CompletedTransactions;
}
}
Вопрос
Пожалуйста, помогите мне в этом, что яделать неправильно в моем коде.Как правильно связывать данные с RadListView, используя Angular.Я использую angular 6 с nativescript.