Open joesan opened 7 years ago
Hi @joesan, Thanks for getting in touch and appreciation.
You are calling the function while binding, that's the issue.
it should be
this.searchPowerPlants.bind(this)
Also, you should set the scrollCallback at declaration.
Right now you are reassigning everytime searchPowerPlants
is called
Let me know..
I figured how by working through the errors that I got and I exactly did what you have posted. You can see my example here:
https://github.com/joesan/plant-simulator-ui/blob/master/src/app/home/home.component.ts
I have one other question though. In my home.html screen, I have a Search button. When I load this page, I call the searchPowerPlants(), bind the method for scrolling. But later on when the user enters a search criteria, I would like to clear the existing results, present the new results and any subsequent scrolling should satisfy this new search criteria.
Have you got any ideas as to how I could do this?
@joesan Sorry couldn't get back to you sooner, I was away.
Do you have a plunker/stackblitz available for this scenario, so I can test it out ?
Do you know if it is easy to import the whole GitHub project into plunker or stackblitz? If not, it is going to be harder for me to set up the whole project! Would it be possible for you to clone it and try it locally? You just need this project and it does not have any other dependency!
I am extremely sorry. somehow I missed this notification.
Hope the implementation went okay.
This is some awesome piece of code and I would like to use it in one of my projects, but however I face some issues when integrating it. What I want is the following:
User has a form where he can enter his search criteria. When he clicks submit, I make a REST API call to fetch the results. The results are transformed into my model class.
By default I only fetch 10 items on every REST API call. So for the first time the user loads these 10 items by clicking the Search button
From next time onwards, I should be able to just scroll down which will in turn load 10 more items from the REST API
I tried to use your scroll directive and I'm stuck with one issue which is in my Typescript which is as below:
In the code above line number 50
this.scrollCallback = this.searchPowerPlants().bind(this);
does not compile! It complains that property bind does not exist on type Observable
Any thoughts on how to get this going? Or Do you have any alternative approach that I could try?