javascriptangularangular2-di

What are the correct token types for DI


In angular1 we had only type of tokens for providers - strings. In angular2 all examples I've seen seem to be using class tokens. For example:

class Car {}

var injector = ResolveInjector.resolveAndCreate([
  { provide: Car, useClass: Car },
             ^^^
  { provide: Engine, useClass: Engine }
]);

I'm wondering what are the valid token types? Are they can based on TypeScript data types or JavaScript datatypes? When resolving dependencies, angular uses metadata. So is valid token types are those that are valid inside metadata?


Solution