Angular ui-router allows me to resolve different injections that I can use in my controllers.
I created a simple generic ListController, and in the ui-router I am in
For future reference, I ended up writing a system of generic controllers, and tiny specialized controllers that extend them.
For the example above, the generic controller is subclassed by both "PeopleController" and "CarController". At the beginning of the controller code, each one of them will do something like:
controller('PeopleController', ['$scope', 'peopleService', function ($scope, peopleService) {
angular.extend(this, $controller('listController', {$scope: $scope, functions:{
add: peopleService.addPerson,
remove: peopleService.removePerson,
[...]
}}));
$scope.people = $scope.itemList;
}
So now I can instantiate the controllers on their own even in the ng-controller directive, and they will use the generic controller for all of the CRUD methods.