从打字稿中的对象数组删除元素时遇到问题

您好,我正在尝试永久删除此对象数组的元素:

 playlists: object[] = [
        { title: 'Ejemplo 1', songs: [ 'cancion1', 'cancion2', 'cancion3'] },
        { title: 'Ejemplo 2', songs: [ 'cancion1', 'cancion2', 'cancion3' ] }
  ];

我尝试使用splice方法,但是当我刷新网页时它再次出现: ´´´ deletePlaylist(index:number){

  this.playlists.splice(index, 1);

} ´´´ 索引来自哪里:

<div *ngFor="let playlist of playlists; let i = index" class="card text-white bg-success m-3 animated fadeIn" style="max-width: 18rem;">
        <div class="card-header">{{ playlist.title }}</div>
        <div class="card-body">
            <h5 class="card-title">{{ playlist.title }}</h5>
            <ul *ngFor="let song of playlist.songs" class="card-text">
                <li>{{ song }}</li>
            </ul>
            <div class="row">
                <div class="col text-right">
                    <button (click) = "deletePlaylist( i )" class="btn btn-danger text-left" ><i class="fas fa-trash"></i></button>
                </div>
            </div>
        </div>
    </div>

有任何想法吗?

评论