概述
Nativescript radListView在ios和android上都没有显示来自组件的绑定项。
操作栏和通常的ListView显示数据,但是radlistview不显示数据。控制台没有显示错误。但是我从下一个存储库中看到了RadListView可以工作-> https://github.com/telerik/nativescript-ui-samples-angular
环境
我的开发环境在下面。
操作系统: macOS塞拉利昂10.12.6
节点: v6.12.0
国家预防机制: 3.10.10
nativescript和其他内容可以在package.json看到
考虑
我觉得这个问题是关于..。
但我不能精炼。
码
我在像下面这样的角度上实现了RadListView,就在“tns创建ui-test -ng”之后。
组件
export class ItemsComponent implements OnInit {
private _dataItems: ObservableArray<Item>;
constructor() {
}
get dataItems(): ObservableArray<Item> {
return this._dataItems;
}
ngOnInit() {
this._dataItems = new ObservableArray([
{ id: 1, name: "Ter Stegen", role: "Goalkeeper" },
{ id: 3, name: "Piqué", role: "Defender" },
{ id: 4, name: "I. Rakitic", role: "Midfielder" }
]);
}
}html
<ActionBar title="My App" class="action-bar">
</ActionBar>
<GridLayout>
<RadListView [items]="dataItems">
<ng-template let-item="item">
<StackLayout>
<Label class="nameLabel" text="text"></Label>
<Label class="nameLabel" [text]="item.name"></Label>
<Label class="descriptionLabel" [text]="item.role"></Label>
</StackLayout>
</ng-template>
</RadListView>
</GridLayout>package.json
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.uitest",
"tns-ios": {
"version": "3.3.0"
}
},
"dependencies": {
"@angular/common": "~5.0.0",
"@angular/compiler": "~5.0.0",
"@angular/core": "~5.0.0",
"@angular/forms": "~5.0.0",
"@angular/http": "~5.0.0",
"@angular/platform-browser": "~5.0.0",
"@angular/platform-browser-dynamic": "~5.0.0",
"@angular/router": "~5.0.0",
"nativescript-angular": "5.0.0",
"nativescript-fresco": "^3.0.2",
"nativescript-intl": "^3.0.0",
"nativescript-pro-ui": "3.3.0",
"nativescript-unit-test-runner": "^0.3.2",
"rxjs": "^5.5.2",
"tns-core-modules": "3.4.0",
"zone.js": "~0.8.2"
},
"devDependencies": {
"nativescript-dev-typescript": "~0.5.0",
"typescript": "~2.4.2"
}
}发布于 2018-01-12 14:30:43
我解决了自己。RadListView需要一个getter和一个ObservableArray实现,并且需要正确的html编码。我没有填充像行这样的参数。
但我不知道如何很好地使用radListView。现在,我在使用另一个radListView布局时遇到了麻烦。
发布于 2018-12-01 16:07:02
我确实得到了您的代码,并在tns创建后放入了home.component,然后tns插件添加了nativescript-ui-listview tns平台,删除了android tns平台,添加了android tns构建android tns运行android
如果您没有忘记在home.module.ts : NativeScriptUIListViewModule中导入这个模块,它就能工作。
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptCommonModule } from "nativescript-angular/common";
import { NativeScriptUIListViewModule } from "nativescript-ui-listview/angular";
import { HomeRoutingModule } from "./home-routing.module";
import { HomeComponent } from "./home.component";
@NgModule({
imports: [
NativeScriptCommonModule,
HomeRoutingModule,
NativeScriptUIListViewModule
],
declarations: [
HomeComponent
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class HomeModule { }用这个item.model.ts
export class Item {
id: number;
name:string;
role: string;
}重要
在另一个项目中,直到我在app.module.ts中添加了这些行之后,它才起作用。
import { NativeScriptUIListViewModule } from "nativescript-ui-listview/angular/listview-directives";
@NgModule({
imports: [
...
NativeScriptUIListViewModule发布于 2018-01-04 23:56:25
你试过_dataItems而不是dataItems吗?看起来,您已经定义了一个项目源,并在没有_的情况下引用了它。
https://stackoverflow.com/questions/48078041
复制相似问题