I came up with a working solution, but I wonder if this is a correct
solution. I have the Service build an Array of Models and return a
Promise<Array<Model>>. Still wonder if this it the appropriate way of
implementing a DAO.
On Thursday, November 12, 2015 at 11:09:19 AM UTC-5, JG wrote:
>
> I posted this on Stack Overflow, but I am not sure that I tagged it
> correctly. Sorry if this is a duplicate.
>
>
>
> This is more of a "best practices" question. There are three players: a
> *Component* a *Service* and a *Model*. The Component is calling the
> Service to get data from a database. The Service is using
>
> this.people = http.get('api/people.json').map(res => res.json());
>
> to return an Observable.
>
> The Component could just subscribe to the Observable:
>
> peopleService.people
> .subscribe(people => this.people = people);
> }
>
> But what I really want is for the Service to return an Array of Model
> objects that was created from the data that the Service retrieved from the
> database. I realize that the Component could just create this array in the
> subscribe method, but I think it would be cleaner if the service do that
> and make it available to the Component. How can the Service create a new
> Observable, containing that array, and return that?
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.