I have an Angular.js application and I need to call three different resources and once they all complete, use them together. My three calls are below.
# Get the curriculum
$scope.curriculum = CurriculumResource.get id: $routeParams.id
# Get the list of courses
$scope.courses = CourseResource.query()
# Get the list of groups
$scope.groups = GroupResource.query()
How can I perform more logic once I know the requests are all completed. I've tried using $watchGroup shown below and $watchCollection but neither seem to be working.
$scope.$watchGroup ['curriculum', 'courses', 'groups'], ->
# Shouldn't this run each time something in the above array changes?
console.log 'Only runs once'
# The values of the items in the below if statement eventually give a true result
# but the if statement never runs when they are true
if $scope.curriculum.groups and $scope.groups.length
console.log 'never gets here!'