Reputation: 32680
I have two directives - call them "mainPane" and "sidePane", each of which displays a list of items. The content of these two lists often overlaps - i.e. the same item is displayed in both lists - and the user can interact with items in either list. When the user changes something in an item in one list, I want it to be reflected immediately in the other list. That's my primary requirement.
I'm fairly certain that I want to store all my items in a Content
service, where I'll also encapsulate the (AJAX) retrieval logic.
What I'm looking for is high-level advice about the best way to structure that service from there. Does it have two separate lists, one for each pane? If so, what do I do about items that are present in both? Storing all items in a single array and filtering it to produce the two separate lists is appealing, but unfortunately there's no inherent property of these items that determines which list they should appear in. I could make one, though - I could add an onMainPane
and onSidePane
field to these objects and filter on that. Is that the best way to go - and if so, should I do the filtering in the service or in the directives?
Or is there a better option?
Upvotes: 0
Views: 36
Reputation: 180
Since you already creating Content
service for encapsulation, leveraging that would be logical. Content
service could be injected into the directive and share the list.
That being said, how large will be the lists? How complex will the directives/content items be? If the objects/directive are complex and the list large, the service route many not be suitable.
Upvotes: 0