I am trying to return data from server using meteor methods from inside a angular2 service
my question is how to return the data to my component if the call happen async? It was easy when the calls was inside my component, but moving it to a service made me get stuck.
You can div ngFor=“let listitem of myservice.list”
…
Why not declare a Mongo.Cursor in your service, fill it with a query and use it directly?
I’m finding that the least code in the component, the better. Handle events, instantiate, but have the template use the service data directly.
In the template myobservable$ | async subscribes to the observable.
I’m still working this out, but a template that talks to a service can talk to a different service with the same API interface, allowing reuse. My app will have lots of similar tree type views with similar actions, so even a different component service combination with the same outward facing interfaces can save me lots of development time.
I am not using a Mongo.Cursor because I change the data before return, so it’s different from the collection and I may also get data from others sources, not just mongo.
Hi, @adrianolsk
I believe there is always better way. That is my feeling when I am using Angular 2 and Meteor.
I am also trying to explore all potential of Angular 2 and Meteor. : )
If I found any really good way, I will share it here.
There are so much potential for Angular 2 and Meteor, just keep learning!