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

Ionic 2 - not working inside "ion-card" directive #196

Closed
walfro opened this issue Aug 22, 2017 · 11 comments
Closed

Ionic 2 - not working inside "ion-card" directive #196

walfro opened this issue Aug 22, 2017 · 11 comments

Comments

@walfro
Copy link

walfro commented Aug 22, 2017

Hi there,

I'm facing this issue with Ionic 2:

Basically, what is happening is that when the img tag is inside the ion-card directive the image is not loading at all, it only shows the "defaultImage". Positioning the image outside the ion-card it works OK.

Please let me know if you can take a look at this.

in place.ts
...
export class PlacePage {

defaultImage: string = 'http://via.placeholder.com/350x150';
place: any = {
imgUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSSCP8YYuzKCXQLhQ7mkH5I_VpZ0v23BWrJ4QkxSSldl7sOV__xKA'
};

constructor() {
}

...
}

in place.html:
<ion-card> <img [defaultImage]="defaultImage" [lazyLoad]="place.imgUrl" /> ..... </ion-card>

Thanks

@tjoskar
Copy link
Owner

tjoskar commented Aug 22, 2017

Hi,

Are the ion-cord inside some view or anything that has its own scroll container? Can you give me more of your view?

@walfro
Copy link
Author

walfro commented Aug 22, 2017

Thanks for the quick reply.

Here is what my view basically has:

** all that wrapped in a "ion-content" but for some reason is not being properly formatted here.

<ion-card>
    <img defaultImage]="defaultImage" [lazyLoad]="place.imgUrl" />

    <ion-card-content>
        <ion-card-title>
            <div>{{place.name}}</div>
        </ion-card-title>
        <div>
            Some content here ....
        </div>
    </ion-card-content>
</ion-card>

@tjoskar
Copy link
Owner

tjoskar commented Aug 23, 2017

I think ion-content can be the problem. ng-lazyload-image are using window per default for scroll events but ion-content is using their own scroll container so we need to listen for scroll event on ion-content.

Can you try to use the following template:

<ion-content #container>
  <ion-card>
    <img defaultImage]="defaultImage" [lazyLoad]="place.imgUrl" [scrollTarget]="container.scrollElement" />
    you content
  </ion-card>
</ion-content>

@walfro
Copy link
Author

walfro commented Aug 23, 2017

Thanks for looking into this,

I have tried with the provided code but made no difference, I think ion-content is not the problem and ion-card might be, because if you take the img tag outside the ion-card it works just fine.

Did you try to reproduce it from your side? I could share a project in bitbucket in case you didn't.

Thanks

@tjoskar
Copy link
Owner

tjoskar commented Aug 23, 2017

Humm, okay. Yeah, that would be super nice if I could get access to your project :) I'm using tjoskar as username on bitbucket if it is a close project.

@tjoskar
Copy link
Owner

tjoskar commented Nov 5, 2017

Did you solve the problem? I will close this issue now but feel free to reopen it.

@tjoskar tjoskar closed this as completed Nov 5, 2017
@jcbowyer
Copy link

I am having a similar problem that may be related to endless scrolling. My project in development is http://veterinary.communityone.com , you would have to create a login to see the content then click on social feed from the sidebar once logged in. The initial page shows the image fine but once endless scrolling begins the first image reverts to a spinner and never appears again.

capture

@tjoskar
Copy link
Owner

tjoskar commented Dec 30, 2017

@jcbowyer, I just created an account but I could not reproduce the problem. I only three posts and did not get any infinite scroll.

@jcbowyer
Copy link

Thanks I eventually changed something and it started working. I’m not sure exactly what fixed it

@jeffreyramia
Copy link

@tjoskar Same issue here. Any potential fix for this?

@tjoskar
Copy link
Owner

tjoskar commented Apr 30, 2018

@jeffreyramia, same issue? Are you also using ionic and ion-card? Can you open a new issue and describe the issue and maybe share some code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants