Skip to main content

Posts

Showing posts with the label Dependency Injection in Angular 2

Dependency Injection (DI) in Angular 2 [Why @Injectable()?]

Dependency Injection is a powerful pattern for managing code dependencies. Angular 2 Dependency Injection  consists of three things.               1.        Injector               2.        Provider               3.        Dependency Injector :- The injector object use to create instances of dependencies. Provider :- A provider is help to injector for create an instance of a dependency. A provider takes a token and maps that to a factory function that creates an object. Dependency :- A dependency is the type of which an object should be created. When use @Inject()? When Use @Injectable ()? @Injectable() vs. @Inject() ? How to use Dependency Injection (DI) correctly in Angular 2? ...