AngularJS - please explain the line

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 $route and $xhr are native AngularJS services, the latter has been replaced by $http in the most recent versions of AngularJS. They are part of the ng module.

You can read about them here

$inject tells angular to make available those services to the controller PhotoGalleryCtrl

Dependency 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