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

Can't place InfiniteScroll inside custom component #6531

Closed
lbickston opened this issue May 14, 2016 · 22 comments · Fixed by #10507
Closed

Can't place InfiniteScroll inside custom component #6531

lbickston opened this issue May 14, 2016 · 22 comments · Fixed by #10507
Assignees
Milestone

Comments

@lbickston
Copy link

I would like to create a custom component and place infinite scroll inside of it.

So instead of this:

<ion-content>

 <ion-list>
   <ion-item *ngFor="#i of items"></ion-item>
 </ion-list>

 <ion-infinite-scroll (infinite)="doInfinite($event)">
   <ion-infinite-scroll-content></ion-infinite-scroll-content>
 </ion-infinite-scroll>

</ion-content>

I would like to create a custom component and do this:

<ion-content>
  <my-list></my-list>
</ion-content>

This doesnt work. Instead I get this error message:
browser_adapter.ts:73 ORIGINAL EXCEPTION: No provider for Content! (InfiniteScroll -> Content)

Maybe InfiniteScroll needs to be able to look for ion-content in its parent/ancestor components?

Which Ionic Version? 2.x

Run ionic info from terminal/cmd prompt: (paste output below)

Cordova CLI: 6.1.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.6
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v5.5.0
Xcode version: Xcode 7.3 Build version 7D175

@lbickston lbickston changed the title Can't place InfiniteScroll inside component without <ion-content> Can't place InfiniteScroll inside custom component May 14, 2016
@Nodonisko
Copy link

Same problem is with PullToRefresh component.

@joshgarwood
Copy link

I'm also having this issue. Any possibility of a fix making it into milestone Beta 11 or Beta 12, @brandyscarney ?

Thanks!!

@itaydemri
Copy link
Contributor

Same problem with Beta 11. any fix in Beta 12?

@wundo
Copy link

wundo commented Sep 5, 2016

Samething here

Ionic Framework Version: 2.0.0-beta.8
Ionic CLI Version: 2.0.0-beta.32
Ionic App Lib Version: 2.0.0-beta.18
ios-deploy version: 1.8.6
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v5.6.0
Xcode version: Xcode 7.3.1 Build version 7D1014

@alexmgrant
Copy link

amen to this.

@wo2888
Copy link

wo2888 commented Sep 22, 2016

I need you help to resolve this problem

@marcioluis
Copy link

You must add the 'Content' to the viewProviders.
It breaks the css margin of the root ion-content but works...

`
import { Content } from 'ionic-angular';

@component({
selector: 'new-list',
templateUrl: 'list.html',
viewProviders: [Content]
})
export class MyNewComponent{}`

@scferg
Copy link

scferg commented Nov 30, 2016

I was able to get around the ORIGINAL EXCEPTION: No provider for Content! error by doing @marcioluis's sugestion. However, now I get the following error:

EXCEPTION: Error in ./PhotoListComponent class PhotoListComponent - inline template:17:0 caused by: Cannot read property 'removeEventListener' of undefined

If I remove <ion-infinite-scroll> from the template (line 17), the error goes away. It seems this might be related to #5760, but it was supposedly fixed and closed.

Any ideas?

ionic info
Cordova CLI: 6.0.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v4.2.6
Xcode version: Xcode 8.1 Build version 8B62

@mebibou
Copy link

mebibou commented Dec 2, 2016

Same issue here and solution not working, any solution from ionic team? :)

@scferg I don't think it is related as the issue is about leaving the page, and the content was already found and bound to events, this looks like it cannot find the ion-content element.

@scferg
Copy link

scferg commented Dec 8, 2016

@mebibou I agree, it's not that issue, but it's the only issue I could find that seemed to have any relevance with this error. I'm surprised more people haven't brought this up...

A response from the team would be great. I can't ship my app without this being supported (or without finding a crazy workaround) since my custom list component has complex logic that I don't want to duplicate for every page it needs to appear on.

I've started trying to see if I can leave ion-infinite-scroll out of the custom component and include it on the page itself, but I'm having a hard time connecting the two logistically.

@skoubin
Copy link

skoubin commented Dec 8, 2016

Have you tried to wrap your custom component with an extra ion-content element?

I faced the same problem and this is how I got rid of the error "ORIGINAL EXCEPTION: No provider for Content! (InfiniteScroll -> Content)"

My custom component looks like

<ion-content>
    <ion-list>
    .......
    </ion-list>
    <ion-infinite-scroll (ionInfinite)="loadMore($event)">
      <ion-infinite-scroll-content loadingSpinner="bubbles"
                           loadingText="Loading more..."></ion-infinite-scroll-content>
    </ion-infinite-scroll>
</ion-content>

and the page, that uses it, looks like

<ion-header>....</ion-header>
<ion-content>
    <custom-component></custom-component>
</ion-content>

I am not sure whether this extra ion-content has any other implications but it looks fine so far!

@scferg
Copy link

scferg commented Dec 8, 2016

@skoubin I have tried that haha. At first it looked fine, but then it seemed to be causing jagged page transitions, but now that I've tried this approach again, it no longer seems to be the case. It must've been something I was doing wrong.

The only remaining issue with this approach is that <ion-content fullscreen> is messed up, which is what @marcioluis pointed out. It'll take some css hacks to restore it.

It's a hacky approach since <ion-content>, <div class="fixed-content">, and <div class="scroll-content"> are all unnecessarily duplicated, but it seems to be the best solution for now.

Edit: Buggy page transitions do still seem to be an issue with this approach. If the page with the custom component (and duplicate ion-contents) is the first in a stack and you navigate away from (or back to) it, everything is fine. It seems that when the page with the custom component is not the first in the stack (therefore, it's pushed in from another page), the transition is jumpy. See below.
Page transition bug

@captaincole
Copy link
Contributor

As of RC4 I am still seeing this issue and would also appreciate a decent resolution.

@JustasKuizinas
Copy link

Have same issue, infinitescroll doesnt work inside custom components

@AlQuraian
Copy link

I managed to avoid the issue by moving ion-infinite-scroll out of the component and into the page (The ion-content is only in the page). Then delegating the 'ionInfinite' event as such:
<ion-content>
<list #list></list>
<ion-infinite-scroll (ionInfinite)="list.doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>

It seems to be working fine for me.

@captaincole
Copy link
Contributor

@AlQuraian It seems that this solution does not work for me. I added this and created a custome component with an event doInfinite, but the search breaks when I call it.

Where

  <workout-search #workouts></workout-search>
	<ion-infinite-scroll *ngIf="moreData" (ionInfinite)="workouts.doInfinite($event)">
    <ion-infinite-scroll-content></ion-infinite-scroll-content>
  </ion-infinite-scroll>

And in workout-search.comp

  doInfinite($event) {
    console.log('Infinite Event');
  }
Error in ./DiscoverPage class DiscoverPage - caused by: self.parentView.context.workouts.doInfinite is not a function

@MankinPT
Copy link

MankinPT commented Feb 1, 2017

@AlQuraian @thielCole AlQurain solution works, but is not elegant or very practical reproducing the doInfinite logic every time you want to use the component (it's against what a component is suppose to represent).

@captaincole
Copy link
Contributor

@MankinPT To get around this, I was using a rxjs Behavior Subject to observe data changes accross components. I did manage to refactor my specific issue to get rid of this dependency but it would still be nice to have.

@AmitMY
Copy link
Contributor

AmitMY commented Feb 17, 2017

Any update on this?

@alexmgrant
Copy link

@PatrickMcD I think you're the very first GitHub troll, congrats.

@captaincole
Copy link
Contributor

Ya!

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 3, 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 3, 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

Successfully merging a pull request may close this issue.