nativescript' this'里面的tkListViewHeader(RadListView头部指令)

时间:2017-05-02 09:04:12

标签: nativescript angular2-nativescript nativescript-telerik-ui

我在nativescript中使用了teleriks RadListView的TKListViewHeaderDirective,如下所示:

<GridLayout columns="*" rows="*" tkToggleNavButton>
    <RadListView *ngIf="!loading" row="3" col="0" [items]="nodes" ...>
        <ng-template tkListItemTemplate let-node="item">
            <!-- list item -->
        </ng-template>
        <ng-template tkListViewHeader>
            <GridLayout columns="*" rows="auto, auto, auto">
                <GridLayout row="0" col="0" columns="40,*,40">
                    <Button class="fa action-item" row="0" col="0" [text]="'fa-sort-amount-asc' | fonticon" ios.position="right" android="actionBar" style="background-color:#c9c9ce;;"></Button>
                    <SearchBar row="0" col="1" #searchInput hint="Search" (submit)="search(searchInput.text)" (clear)="search('')" (textChange)="search(searchInput.text)"></SearchBar>
                    <Button class="fa action-item" row="0" col="2" [text]="'fa-th' | fonticon" ios.position="right" android="actionBar" style="background-color:#c9c9ce;"></Button>
                </GridLayout>
                <StackLayout row="1" col="0">
                    <Label text="Hello world"></Label>
                    <Label [text]="currentNode.name"></Label>
                    <Label [text]="nodes?.length ? nodes.length : 0"></Label>
                </StackLayout>
                <StackLayout row="2" col="0" *ngIf="!nodes?.length" class="list-group">
                    <!-- some contents -->
                </StackLayout>
                <StackLayout row="3" col="0" *ngIf="currentNode?.name !== '/'" class="list-group">
                    <!-- some contents -->
                </StackLayout>
            </GridLayout>
        </ng-template>
    </RadListView>
</GridLayout>

这似乎有两件事情出错:

  1. this似乎在这里丢失(* ngIf应该在特定情况下显示其中一个StackLayouts但不会
  2. GridLayout(如果我将其更改为StackLayout没有任何效果)列表标题内只显示一个子元素
  3. 根据文档:http://docs.telerik.com/devtools/nativescript-ui/Controls/Angular/ListView/header-footer

1 个答案:

答案 0 :(得分:0)