What exactly does the “inject” line do?:
function PhotoGalleryCtrl($route, $xhr) {
}
PhotoGalleryCtrl.$inject = ['$route', '$xhr'];
Are $route and $xhr predefined somewhere? Where to read about them?
Who said that the PhotoGalleryCtrl function has the .$inject method?
Both
$routeand$xhrare native AngularJS services, the latter has been replaced by$httpin the most recent versions of AngularJS. They are part of thengmodule.You can read about them here
$injecttells angular to make available those services to the controllerPhotoGalleryCtrlDependency injection and modules are core features of Angular. They both minimize global state and allow for better unit testing, you can read more about them here