简体   繁体   English

在带有Angular的Ionic 4中使用Slider看不见Slide中的组件

[英]Component in Slide not visible using Slider in Ionic 4 with Angular

My desired effect is to to have a different specified component load in a slide depending on the data using a switch statement. 我想要的效果是使用switch语句根据数据在幻灯片中加载不同的指定组件。 My issue is that I do not see anything in my slides and I'm not receiving an error. 我的问题是我的幻灯片没有看到任何内容,也没有收到错误消息。 I think this may be an issue solvable by css, but when I change the components height and width too 100% I don't see anything. 我认为这可能是CSS可以解决的问题,但是当我将组件的高度和宽度更改为100%时,我什么也看不到。 I have also tried using fullscreen="true" on the component. 我也尝试在组件上使用fullscreen =“ true”。

In my data structure I have an array of "pageType"s that I want to trigger a switch statement to open a specified angular component. 在我的数据结构中,我有一个“ pageType”数组,我想触发一个switch语句来打开指定的角度分量。

<ion-content>
  <ion-slides *ngIf="pages"
    [options]="sliderConfig">
    <ion-slide *ngFor="let index of pages">

  <div [ngSwitch]="index.pageType">
    <app-std-layout *ngSwitchCase="'std'" [flashCards]="index.flashCards"></app-std-layout>
    <app-std-layout *ngSwitchDefault [flashCards]="index.flashCards"></app-std-layout>
  </div>

    </ion-slide>
  </ion-slides>

</ion-content>

My standard layout component looks as follows~ 我的标准布局组件如下所示〜

<ion-content fullscreen="true">

  <ion-grid>
    <ion-row>
      <ion-col *ngFor="let flashcard of flashCards">
          <app-flashcards [flashcard]="flashcard"></app-flashcards>
      </ion-col>
    </ion-row>
  </ion-grid>

</ion-content>

Both of your switch statements seem to be trying to do the same thing at the moment? 您的两个switch语句目前似乎都在尝试做相同的事情?

For your app-std-layout , in the code, do you have the @Input() on the flashCards so that pulls the information in? 为了您的app-std-layout ,在代码中,你有没有@Input()flashCards ,这样拉动的信息?

Have you tried putting some normal words inside like "TEST" just to see if the component is being output? 您是否尝试过在“ TEST”之类的单词中添加一些普通单词,以查看是否正在输出组件?

Ok so I solved my issue. 好的,所以我解决了我的问题。 In <app-std-layout> component I need to get rid of the <ion-content> tags <app-std-layout>组件中,我需要摆脱<ion-content>标签

<ion-grid>
  <ion-row>
    <ion-col *ngFor="let flashcard of flashCards">
      <app-flashcards [flashcard]="flashcard"></app-flashcards>
    </ion-col>
  </ion-row>
</ion-grid>

I suppose <ion-content> tags cannot be embedded in one another. 我想<ion-content>标签不能相互嵌入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM