The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Understand Angular @Injectable

Understand Angular @Injectable

4:27
In order to resolve a dependency, Angular’s DI uses type annotations. To make sure these types are preserved when transpiled to ES5, TypeScript emits metadata. In this lesson we’ll explore how the @Injectable decorator ensures metadata generation for services that have their own dependencies.
Watch this lesson now
Avatar
egghead.io

In order to resolve a dependency, Angular’s DI uses type annotations. To make sure these types are preserved when transpiled to ES5, TypeScript emits metadata. In this lesson we’ll explore how the @Injectable decorator ensures metadata generation for services that have their own dependencies.

Avatar
Michael

The end result is a bit weird in my opinion. The ListComponent is the component configuring the LogService and the ConsoleService but the DataService is the one using them! This breaks all encapsulation don't you think?

Avatar
Michael

Unless you consider the ListComponent the main file of the application where all configurations for injectable components is made. (such as the the FactoryProvider for LogDebugger). Does this mean then that this configuration is GLOBAL for all components? What happens if another component defines another FactoryProvider for LogDebugger?

In reply to Michael
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?