From 7ee3d5846c9dd0f30f0737b023b0de688664fbad Mon Sep 17 00:00:00 2001 From: Vlad Tansky Date: Mon, 13 Sep 2021 12:33:25 +0300 Subject: [PATCH] fix(angular): deprecate `[(index)]` and `setIndex()` (#4951) --- playground/angular/src/app/home/home.component.html | 6 ------ playground/angular/src/app/home/home.component.ts | 1 - src/angular/src/swiper.component.ts | 6 +++++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/playground/angular/src/app/home/home.component.html b/playground/angular/src/app/home/home.component.html index 84f980a02..0dd418d9e 100644 --- a/playground/angular/src/app/home/home.component.html +++ b/playground/angular/src/app/home/home.component.html @@ -114,7 +114,6 @@

Custom pagination

[breakpoints]="breakpoints" [scrollbar]="scrollbar" [loop]="true" - [(index)]="indexNumber" [pagination]="{ el: '.swiper-pagination.pagination-test' }" > @@ -134,11 +133,6 @@

Custom pagination

- - - - - {{ indexNumber }} Best slide ever 2 diff --git a/playground/angular/src/app/home/home.component.ts b/playground/angular/src/app/home/home.component.ts index 42ff07838..aabe19cf9 100644 --- a/playground/angular/src/app/home/home.component.ts +++ b/playground/angular/src/app/home/home.component.ts @@ -56,7 +56,6 @@ export class HomePage { this.controlledSwiper = swiper; } - indexNumber = 1; exampleConfig = { slidesPerView: 3 }; slidesPerView: number = 4; pagination: any = false; diff --git a/src/angular/src/swiper.component.ts b/src/angular/src/swiper.component.ts index e81ba2624..3a7ef4a06 100644 --- a/src/angular/src/swiper.component.ts +++ b/src/angular/src/swiper.component.ts @@ -234,6 +234,7 @@ export class SwiperComponent implements OnInit { @Input() set index(index: number) { + console.warn('`[(index)]` prop is deprecated and will be removed in upcoming versions'); this.setIndex(index); } @Input() @@ -821,8 +822,11 @@ export class SwiperComponent implements OnInit { } else { this.swiperRef.params[_key] = value; } + this.setIndex(2); } - + /** + * @deprecated will be removed in upcoming versions + */ setIndex(index: number, speed?: number, silent?: boolean): void { if (!this.isSwiperActive) { this.initialSlide = index;