简体   繁体   English

无法在 Angular 中绑定 imageUrl

[英]Cant bind imageUrl in Angular

Please help guys!请帮助伙计们! I'm getting datas from https://developers.giphy.com/ , and passing them to a modal for viewing, every other data is showing except for imageUrl.我从https://developers.giphy.com/获取数据,并将它们传递给模式进行查看,除了 imageUrl 之外的所有其他数据都显示。 (what I'm I doing wrong, why wont the gif show) (我做错了什么,为什么不显示gif)

Check below for my code在下面检查我的代码

here is the method calling the api这是调用 api 的方法

data = new BehaviorSubject<any>([]);


  search(event){
    this.http
       .get(
         this.searchEndpointGiphy +
           "api_key=" +
           giphyKey +
           "&q=" +
           event.target.value +
           "&limit =" +
           limit +
           "&offset=" +
           offset +
           "&rating=" +
           rating +
           "&lang=en",

       )
       .subscribe((gifData: any) => {
         this.data.next(gifData.data);
       }
       );
       this.modalPopUp();
   }

here is the modalPopup am also passing data to my modal here这是 modalPopup 我也在这里将数据传递给我的模态


  modalPopUp() {
        const modalRef = this.modalService.open(ModalPopUpComponent);
    modalRef.componentInstance.data = this.data;
  }

finally my modal html file最后是我的模态 html 文件

<div class = "container" *ngFor="let d of data | async">
  <div class = "row">
    <div class = "col-12 col-6">
    </div>
    <div class = "col-12 col-6">
      <div class="card">
        <img [src]="d.url" class="card-img-top img-fluid">
        <div class="card-body">
          <h5 class="card-title">{{d.title}}</h5>
        </div>

      </div>
    </div>
  </div>
</div>

Please why is the imageUrl not displaying??, Have tried all the questions/answers I saw here, but none was able to fix my problem请问为什么imageUrl没有显示??,已经尝试了我在这里看到的所有问题/答案,但没有一个能够解决我的问题

Try to add this in your index.html file尝试将其添加到您的 index.html 文件中

<meta name="referrer" content="no-referrer"/>

From the screenshot shown in this link ( https://ibb.co/XSL1qWp ), I can see an "images" object.从这个链接( https://ibb.co/XSL1qWp )中显示的屏幕截图中,我可以看到一个“图像”object。 Also, the extract shown below from Giphy Docs shows you should look inside the "images" object for different versions of the gif you intend to display, I think you should access the images object instead of that URL field.此外,下面显示的Giphy Docs的摘录显示,您应该在“图像”object 中查看您打算显示的不同版本的 gif,我认为您应该访问图像 object 而不是 ZE6B391A8D2C4D45902DZ23A8 字段。

  1. We provide various renditions of each GIF in the images object to give your users the best experience possible.我们在图像 object 中提供每个 GIF 的各种再现,以尽可能为您的用户提供最佳体验。 Generally, it's best to use the smaller fixed_height or fixed_width renditions on your preview grid.通常,最好在预览网格上使用较小的 fixed_height 或 fixed_width 再现。

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

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