使Nativescript Telerik UI RadListView在Angular中工作

dot*_*dot 5 listview nativescript angular2-nativescript nativescript-telerik-ui

TNS v2.5.0

我已经导入LISTVIEW_DIRECTIVES了我的app.module,我的模板看起来像

<ActionBar title="Events"></ActionBar>
<StackLayout orientation="vertical">
    <RadListView [items]="events">
        <template tkListItemTemplate let-event="item">
            <StackLayout orientation="vertical">
            <Image [src]="'https:' + event.image" stretch="aspectFit"></Image>
            <Label [nsRouterLink]="['/event', event.id]" [text]="event.title"></Label>
            </StackLayout>
        </template>
    </RadListView>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)

但这只显示为常规ListView可以正常显示。

另外,如果我尝试一个GridLayout喜欢

<ActionBar title="Events"></ActionBar>
<GridLayout>
    <RadListView [items]="events">
        <template tkListItemTemplate let-event="item">
            <StackLayout orientation="vertical">
            <Image [src]="'https:' + event.image" stretch="aspectFit"></Image>
            <Label [nsRouterLink]="['/event', event.id]" [text]="event.title"></Label>
            </StackLayout>
        </template>
    </RadListView>
</GridLayout>
Run Code Online (Sandbox Code Playgroud)

该应用程序崩溃并显示错误消息

file:///app/tns_modules/nativescript-telerik-ui/listview/listview.js:1034:104:JS错误TypeError:未定义不是一个对象(正在评估'itemViewDimensions.measuredWidth')2月5日11:40:53 Marcuss -iMac com.apple.CoreSimulator.SimDevice.1A8C1E25-DAC0-4BA0-822E-5A6F731F1CD7.launchd_sim [31919](UIKitApplication:org.nativescript.t4g [0x7b2a] [36194]):由于分段错误而退出了服务:11

不知道我是否错过了某个地方的导入,但是文档非常粗略,因此很难确定并查看示例

小智 5

LISTVIEW_DIRECTIVES 适用于带有 Javascript 的 Nativescript。

对于 Angular2:

安装插件tns plugin 在此重建添加 nativescript-telerik-ui使用 tns run android 以使新插件工作。

module.ts添加:

从“nativescript-telerik-ui/listview/angular”导入 { NativeScriptUIListViewModule };

并在同一个文件中:

在@NgModule导入中添加:NativeScriptUIListViewModule,

它会准备好。


Edd*_*gen 0

我不确定它是必需的,但我RadListView在一个项目中拥有它,并且还ListViewLinearLayout作为它的子项目之一:

<RadListView [items]="listViewItems">
  <ListViewLinearLayout tkListViewLayout scrollDirection="Vertical"></ListViewLinearLayout>
  <template tkListItemTemplate let-item="item">
    <YourStuff></YourStuff>
  </template>
</RadListView>
Run Code Online (Sandbox Code Playgroud)

您是否也添加到应用程序模块LISTVIEW_DIRECTIVES的列表中?declarations