Динамические изображения Carosel не отображаются с помощью ngFor (Angular 7) - PullRequest
0 голосов
/ 27 марта 2019

Я настраиваю карусель для отображения динамических изображений, извлекаемых из Node API.Я использую директиву ngFor в Angular 7

Вот мой код, который я пробовал:

TypeScript:

getPromotions() {
    this.dashboardService.getPromotions()
      .subscribe(res => {

          this.promotions = res.listings.map(res => {
            return {image: `data:${
              res.file_mime_type
              };base64,${this.dashboardService.bufferToString(res.file_content.data)}`}
            });


        console.log('Promotions::', this.promotions);

      }, err => {

      })
  }

html:

<div class="card">
    <div class="card-body">
        <ngb-carousel>
            <ng-template ngbSlide *ngFor="let promotion of promotions">
                <img [src]="promotion.image" height="392" class="d-block w-100" alt="Random slide">
                <div class="carousel-caption">
                    <h3>No Promotion</h3>
                    <p>There is not active Promotion.</p>
                </div>
            </ng-template>
        </ngb-carousel>
    </div>
</div>

Этот код должен показывать изображения в массиве рекламных акций, но он ничего не показывает.

...