NativeScript RadListView 组件模板

NativeScript RadListView component template

我正在尝试使用 Angular 组件作为 RadListView 的模板。

<StackLayout>
  <RadListView [items]="stories"
               marginRight="-2"
               separatorColor="transparent"
               height="100%">
    <ng-template tkListItemTemplate
                 let-story="item">
      <NewsItem [story]="story"></NewsItem>
    </ng-template>
  </RadListView>
</StackLayout>

我收到以下错误。

file:///app/tns_modules/tns-core-modules/ui/core/view/view.js:57:124: JS ERROR Error: onMeasure() did not set the measured dimension by calling setMeasuredDimension() ProxyViewContainer(435)

想通了。模板本身必须有一个容器。

<StackLayout>
  <RadListView [items]="stories"
               marginRight="-2"
               separatorColor="transparent"
               height="100%">
    <ng-template tkListItemTemplate
                 let-story="item">
      <StackLayout>
        <NewsItem [story]="story"></NewsItem>
      </StackLayout>
    </ng-template>
  </RadListView>
</StackLayout>