首页 文章

在NativeScript中使用RadListView很难

提问于
浏览
1

这是我第一次在StackOverflow上提问,所以我听起来可能很奇怪 . 请忍受我 . 所以,我正在用TypeScript和Angular编写一个NativeScript程序 . 我想在nativescript-telerik-ui中使用 RadListView ,但它不太合适 .

这就是我的 app.component.ts 看起来像:

import {Component} from "@angular/core";
import {RouteConfig} from "@angular/router-deprecated";
import {HTTP_PROVIDERS} from "@angular/http";
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router";

import {test} from "./pages/test.component";

@Component({
selector: "main",
    directives: [NS_ROUTER_DIRECTIVES],
    providers: [NS_ROUTER_PROVIDERS, HTTP_PROVIDERS],
    template: "<page-router-outlet></page-router-outlet>"
})
@RouteConfig([
    { path: "/test", component: test, name: "test", useAsDefault: true }
])
export class AppComponent {}

这是我的 test.component.ts

import {Component, ViewChild, ElementRef, OnInit} from "@angular/core";
import {Page} from "ui/page";

@Component({
    selector: "test",
    templateUrl: "pages/test.html",
    styleUrls: ["pages/test-common.css", "pages/test.css"],
    providers: []
})

export class test implements OnInit {

    constructor(private page: Page) {}

    ngOnInit() {}

}

这是我的 test.html

<ActionBar title="RadListView"></ActionBar>

<lv:RadListView id="list-view" items="{{ items }}" xmlns='http://schemas.nativescript.org/tns.xsd' xmlns:lv='nativescript-telerik-ui/listview'>

    <lv:RadListView.listViewLayout>
        <lv:ListViewLinearLayout scrollDirection="Vertical"></lv:ListViewLinearLayout>
    </lv:RadListView.listViewLayout>

    <lv:RadListView.itemTemplate>
        <label text="{{ name }}"></label>
    </lv:RadListView.itemTemplate>

</lv:RadListView>

我希望能够使用 test.component.ts 中的变量项操作 test.html 中的 RadListView . 但是,无论我做什么,此刻都不起作用 . 任何人都可以告诉我如何在一个工作的例子中做到这一点?

非常感谢提前 .

1 回答

相关问题