I'm currently considering an alternative to my current directive handling in AngularJS. At the moment my list controller fetches the data from the server via a service and passes this data to the directives on the list page via a parameter. This works so far and keeps the two way binding, so if a directive changes the data the controller and also other directives notice the change. But it leads to a slightly bigger list controller where all the directives come together. And although the directives get their data passed in as a parameter they still need the dependency to the service which handles data server communication for altering and deleting the data.
The alternative I want to test is to let the directive itself request the data they need from the service. In order to not send the same requests to the server I enable the cache. But with this approach every directive will get a new data object. So if this data object is somehow manipulated in one directive the other directives don't know of this change and will still have the original data object. I could save the fetched data object in the service which requests the data but this will lead into problems if different components want different parts of data, so one components needs item 1 - 10 and the other item 11 to 20. Is there a way to achive this "directives fetch the data themself" approach while keeping the data binding between components? Or is the approach of passing the data into the directive I currently use even better then the alternative I'm thinking of? Would be really nice if someone could share his thoughts on this or point me to some good sources for this topic. -- 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.
