Imagine a case where you have a data service which query a database. For working properly you have to deal with a several $scope variables:
$scope.trackerIds, //Array of objects
$scope.dateTo,
$scope.dateFrom,
Is it best: 1) to compute a value object inside the controller then pass it to a service
for example:
var vo = {
trackers: _.map(trackersIds, function(trackerId, key){
return {
trackerId: trackerId,
geoip : $scope.trackers[trackerId].geoip
}
}),
dates:[$scope.dateFrom.toISOString(), $scope.dateTo.toISOString()],
}
var dataPromise = dataservice.getTracesBuckets(vo);
2) Or send directly the $scope to the service
var dataPromise = dataservice.getTracesBuckets($scope);
In the first case there will be logic in the controller to collect and arrange $scope variables. In the second case the service will be coupled to the controller because he must know about the $scope structure to call the right variables.
I am in a "what is less worth" case, so I wonder if I am not missing something important. I am completely rebuilding my architecture thanks to Johnpapa Angular Style guide but there is no help on this.