这是我第一次在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 回答
1).html文件中的语法与xml文件不同
2)nativescript-telerik-ui在2.0.0-rc.1之前,所以他们正在研究它你可以查看这个链接https://github.com/telerik/nativescript-ui-samples-angular/issues/1#issuecomment-225791969
3)如果你正在使用角度的beta vesion然后检查此链接http://docs.telerik.com/devtools/nativescript-ui/Controls/Angular/getting-started