angularjs - Where should my (angular) data-manipulation logic go when polling for data -
i'm working on first large(ish)-scale angular project.
i have angular service polls , returns json data web-service every 5 seconds.
this data structured this:
- top level - category - item - details - ... more details - item - ... - category 2 - item ...
when polling, categories remain constant, items added on hits webservice.
in many cases displaying "items" category, other times collecting items , filtering them details.
what cleanest way approach kind of thing. i've considered few approaches, not sure best.
- using filters (
{{toplevel | allitems | filter:... }}
) - having service expose different configurations of data using different $scope variables.
- just putting login in controller , exposing different data configurations different scope variables
any thoughts / advice / suggested resources appreciated
when i've done similar things, modify data within controller. i'll have couple functions format data in desired ways. store them within same $scope
variable.
$scope.data - { categories: {...}, allitems: {...}, byid: {...} }
then within view event can used switch way it's being organized. assume work well, depends on how data have, & how you're polling, etc.
Comments
Post a Comment