AngularJS DRY controller structure
The code below represents a situation where the same code pattern repeats in every controller which handles data from the server. After a long research and irc talk at #angularjs I still cannot figure how to abstract that code, inline comments explain the situations: myApp.controller("TodoCtrl", function($scope, Restangular, CalendarService, $filter){ var all_todos = []; $scope.todos = []; Restangular.all("vtodo/").getList().then(function(data){ all_todos = data; $scope.todos = $filter("calendaractive")(all_todos); }); //I can see myself repeating this line in every //controller dealing with