I assume, this is a very basic question, but I did not found any answer elsewhere (I think, this goes in the same direction).
I wonder, if an Angular (2 or 4) service should hold any temporary data.
To illustrate my question, lets assume within the Tour of Heroes, after having fetched the heroes once, I want to be able to search within them without an API-call.
I wonder, if it would make sense to add a loadAndGetHeroes(heroListId)
-method to the service, which returns the list, but also saves the list within a private field in the service.
Then I could add a searchForHeroPattern(pattern)
-method to the service, which does not need an API call but can search on the client and would also be available for other parts of the angular-app.
Is this an intended approach or is there a better way to implement such things?