首页 > 解决方案 > 使用拼接功能删除项目时,轮播动态项目有问题

问题描述

当使用拼接功能删除项目(图像)时,它们会删除所有图像。

 when i delete the item  I want the carousel show the others images not disappear.
<div id="carouselExampleControls " class="carousel slide "
 data-ride="carousel">
  <div class="carousel-inner" >

    <div class="carousel-item" *ngFor="let img of urls; let i = index;
    let isFirst = first" [ngClass]="{active:isFirst}"
    >

      <img  [src]="img" >

      <div class="carousel-caption d-non "
       >

<button type="button" (click)="removeSelectedFile(index)" 
class="btn btn-xs btn-default" >
<img src="../assets/images/delete_delete_exit_1577.png"
           style="width: 20px;" /></button>


      </div>
    </div>

  </div>
  <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

`removeSelectedFile(index)
   { 
    this.urls.splice(index, 1);
     } `

当我删除项目时,我希望轮播显示其他图像不会消失。感谢您的帮助

标签: c#angularcarousel

解决方案


 this.urls = this.urls.splice(index, 1);

推荐阅读