Fork me on GitHub

Dependency Injection

Zeroth uses Angular 2’s dependency injector. As one of the primary goals of Zeroth is to be able to share code between the frontend and backend, it makes sense to use the same injector for both.

It is recommended to read the Angular dependency injection guide, as nearly everything in there applies here, with the only exception being that there are no @Components in the backend. For the backend, the Zeroth framework provides the following class decorators:

  • @Model
  • @Controller
  • @Seeder
  • @Migration
  • @Store
  • @Service

Remember that the fronted of a Zeroth project is Angular 2, so it is important to have a firm grasp on how to work with dependency injection anyway, and that knowledge transfers directly to the backend.