Hi Rodrigo,
Too bad you didn’t build a plunk/fiddle, It would be much easier to show
you how it can be done that way.
I think your controller is overly verbose, unless you stripped out a lot of
code that’s not needed for the question.
this will to exactly the same thing:
TaskManager.controller('TaskController', ['$scope', 'AssignedTasksService',
function($scope, AssignedTasksService) {
$scope.tasks = [];
AssignedTasksService.getAssignedTasks().then(function(tasks) {
$scope.tasks = tasks;
});
}
]);
And no, you don’t need to code another controller for just loading some
different set of tasks.This is where the resolve part of the router comes
in.
when you add an resolve block to your routing, you can decide in there what
tasks are loaded for that route. You can then inject the loaded tasks
directly into your controllers.
For now I will leave this as an exercise for yourself. Still have
questions? don’t hesitate to ask, preferably with an plunk
<http://plnkr.co/edit/tpl:t6EYzpT3VpfMAGsJHKqZ>to backup up your question.
Regards
Sander
--
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.