【问题标题】:How to update an ion-slide after removing an Item?删除项目后如何更新离子幻灯片?
【发布时间】:2022-08-17 20:23:32
【问题描述】:

我在 ion-slide 中有一张卡片列表,每张卡片都有一个关闭图标来删除它。

    <ion-slides >
                <ion-slide *ngFor=\"let item of cart; let i = index\" >
                    <ion-card>
              
                      <ion-img  src=\'close.png\'    (click)=\"removeData(item)\" ></ion-img>                        
                  </ion-card>
  </ion-slide>
              </ion-slides>

主页.ts

async removeData(object) {
    .......
      // get the index of object 
this.dataservice.removeItem(index);
        .....
        }

数据服务服务.service.ts

removeItem(index) {
    return this.getAllItems().then((result) => {
      if (result) {
        result.splice(index, 1);
        return this.storage.set(\'i\', result);
      }
    });
  }

移除卡片后,我希望更新列表或刷新当前页面。我在 removeItem 函数中尝试过 \"this.router.navigate([\"/home\"]);\" 但没有任何改变,\"window.location.reload();\" 从登录开始重新加载所有页面。 您能否提出解决问题的方法?

  • 在 removeData 中传递索引并检查此代码this.cart[index]. splice(index,1)
  • @RaviAshara 你能把它写成答案吗?能够接受

标签: angular ionic-framework


【解决方案1】:

它是通过使用拼接解决的

   this.cart.splice(index, 1);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-12
    • 2018-07-21
    • 1970-01-01
    • 1970-01-01
    • 2018-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多