Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ion-slide set initialSlide not work immediately #9138

Closed
ghost opened this issue Nov 13, 2016 · 4 comments
Closed

bug: ion-slide set initialSlide not work immediately #9138

ghost opened this issue Nov 13, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 13, 2016

Type: bug

Ionic Version: 2.x

Platform: all

On this issue, perhaps I did not describe very clearly。
When I want to change initialSlide in the constructor, but it's still default value, then change to value what I set.

home.ts

export class HomePage {
  images = IMAGES;
  constructor(public navCtrl: NavController) { }
  selectImg(index){
    this.navCtrl.push(SlidesPage,{selectImgIndex:index},{animate:false})
  }
}
export const IMAGES = [
    {url:'assets/img/1.jpg'},
    {url:'assets/img/2.jpg'},
    {url:'assets/img/3.jpg'},
    {url:'assets/img/4.jpg'},
    {url:'assets/img/5.jpg'},
    {url:'assets/img/6.jpg'},
]

home.html

<ion-header>
  <ion-navbar>
    <ion-title>Home</ion-title>
  </ion-navbar>
</ion-header>
<ion-content padding>
  <ion-grid >
    <ion-row wrap>
      <ion-col width-33 *ngFor="let image of images let i=index" >
          <img [src]="image.url" (click)="selectImg(i)">
      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content>

slides.ts

export class SlidesPage {

  slides = [];
  mySlideOptions = {
	initialSlide:0,
	pager:true,
	spaceBetween:10,
  };

  constructor(public navCtrl: NavController,params:NavParams) {
    let index = params.get("selectImgIndex");
	this.slides = IMAGES;
	this.mySlideOptions.initialSlide = index;
  }
  goBack(){
    this.navCtrl.pop({animate:false});
  }
}

slides.html

<ion-content class="img-slide" padding>
  <ion-slides #mySlider [options]="mySlideOptions" (click)="goBack()">
    <ion-slide *ngFor="let slide of slides">
      <img [src]="slide.url" class="slide-image" />
    </ion-slide>
  </ion-slides>
</ion-content>

Forgive my poor English

@jgw96 jgw96 added the v2 label Nov 14, 2016
@AleFons
Copy link

AleFons commented Dec 23, 2016

I'm on RC4 and I can confirm that this bug exists; when you set a specific initialSlide in the options, the slides load the slide at index 0 and then switches to the slide at the index set on initialSlide.

I made a post about it on the forums here which contains an example repo with the bug happening.

Also, this seems to be a duplicate of #7595.

@brandyscarney
Copy link
Member

I'm going to close this since it's a duplicate of #7595 and that has been fixed, but please let me know if you're still having the issue and I'll reopen. Thanks!

@ravi-pandit14
Copy link

initialSlide=1 is not showing in my code
and if i use <ion-slides #mySlider [options]="mySlideOptions" > then its throw error
{error: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'ion-slides'.

  1. If 'ion-slides' is an Angular component and it has 'options' input, then verify that it is part of this module.}

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 1, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants