Как я могу превратить StackLayout с циклом ngFor в прокручиваемый список?

 <StackLayout width="100%" *ngFor="let item of (videos$ | async)">
     <CardView class="studentCard" margin="2" elevation="10" radius="1">
        <GridLayout rows="auto, auto, auto" columns="auto, auto, *">
            <Image [src]="item.snippet.thumbnails.high.url" stretch="aspectFill" colSpan="3" row="0"></Image>
            <Label [text]="item.snippet.channelTitle" textWrap="true" row="2" colSpan="1" ></Label>
            <Label [text]="item.snippet.title" textWrap="true" row="2" col="1" colSpan="2" >></Label>
        </GridLayout>
     </CardView>
 </StackLayout>

Пытался обернуть в ScrollView, не вышло.

Я тоже не мог заставить (items$ | async) работать с ListView, кажется, ngFor не может работать с ListView, нам нужно ng-template для ListView.

Я пробовал следующее, но отображается только первый элемент

<ScrollView>
  <ListView [items]="videos$ | async" class="list-group">
    <ng-template let-item="item">
       <GridLayout  class="list-group-item">
         <Image [src]="item.snippet.thumbnails.high.url"></Image>
         <Label [text]="item.snippet.channelTitle" ></Label>
         <Label [text]="item.snippet.title">></Label>
       </GridLayout>
    </ng-template>
  </ListView>
</ScrollView>

person ishandutta2007    schedule 11.06.2017    source источник


Ответы (1)


Оборачивание всего кода сначала с StackLayout, затем с ScrollView сработало

<ScrollView>
  <StackLayout>

   <StackLayout width="100%" *ngFor="let item of (videos$ | async)">
       <CardView class="studentCard" margin="2" elevation="10" radius="1">
          <GridLayout rows="auto, auto, auto" columns="auto, auto, *">
              <Image [src]="item.snippet.thumbnails.high.url" stretch="aspectFill" colSpan="3" row="0"></Image>
              <Label [text]="item.snippet.channelTitle" textWrap="true" row="2" colSpan="1" ></Label>
              <Label [text]="item.snippet.title" textWrap="true" row="2" col="1" colSpan="2" >></Label>
          </GridLayout>
       </CardView>
   </StackLayout>

  </StackLayout>
</ScrollView>
person ishandutta2007    schedule 11.06.2017