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

ion-slides Cannot read property 'hasAttribute' of undefined #10940

Closed
markisme opened this issue Mar 28, 2017 · 8 comments
Closed

ion-slides Cannot read property 'hasAttribute' of undefined #10940

markisme opened this issue Mar 28, 2017 · 8 comments

Comments

@markisme
Copy link

when use *ngFor ion-slides, get this error when start the page.

Uncaught TypeError: Cannot read property 'hasAttribute' of undefined
    at autoplay (swiper.js:175)
    at startAutoplay (swiper.js:218)
    at initSwiper (swiper.js:164)
    at Slides._initSlides (slides.js:851)
    at slides.js:517
    at SafeSubscriber.schedulerFn [as _next] (async.js:105)
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:223)
    at SafeSubscriber.next (Subscriber.js:172)
    at Subscriber._next (Subscriber.js:125)
    at Subscriber.next (Subscriber.js:89)
    at EventEmitter.Subject.next (Subject.js:55)
    at EventEmitter.emit (async.js:79)
    at Array.<anonymous> (page-transition.js:23)
    at IOSTransition.Animation._fireBeforeReadFunc (animation.js:800)
    at IOSTransition.Animation._beforeAnimation (animation.js:729)

And in swiper.ts ,I see that
https://github.com/driftyco/ionic/blob/master/src/components/slides/swiper/swiper.ts#L206, did it's because the acitveindex is undefined,because when there no data in modal.the swiper is still no slide???
By the way , why the ion-slides remove the options, and use this.slides.attributes=value to modify some hidden options. The options of swiper is awsome, and use very well for us to custom the slides.

@jgw96 jgw96 added the v2 label Mar 28, 2017
@jgw96
Copy link
Contributor

jgw96 commented Mar 28, 2017

Hello, thanks for using Ionic! Could you provide a repo that we can use to reproduce this issue?

@jgw96
Copy link
Contributor

jgw96 commented Apr 5, 2017

Hello, thanks for using Ionic! I am going to close this issue as a duplicate of #10830.

@jgw96 jgw96 closed this as completed Apr 5, 2017
@sayanbrainium
Copy link

I have the solution:
Do like this

<ion-slides *ngIf="slideData && slideData.length" autoplay="5000" class="slideroption" pager="true"   loop="true" speed="300">
	  <ion-slide   *ngFor="let slide of slideData">
                <img src="{{slide.imag}}" />
          </ion-slide>
	</ion-slides>

@nikksan
Copy link

nikksan commented Nov 28, 2017

Thanks for the solution.
However the developers should definitely take a look at this case, it makes no sense that an empty array is illiterated.

@ShilpaPrajapati1992
Copy link

@sayanbrainium : It didn't worked for me.
please provide me working solution , I am using it in below way
<ion-slides *ngIf="property.Lead_MediaInfo && property.Lead_MediaInfo.length" autoplay="5000" class="slideroption" pager="true" loop="true" speed="300">
<ion-slide *ngFor="let media of property.Lead_MediaInfo let i = index;trackBy: customTrackBy">


@Gwardinski
Copy link

this is still broken, and these solutions do not work

@tala9999
Copy link

@sayanbrainium: Your solution helps.

@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

7 participants