Loading…

What is dependency injection in angular 2?

Angular has a robust DI framework that gives declared dependencies to a class upon instantiation. To inject a service, you must first create and register the injectable service.

Example

                                        

import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root', })
export class SampleService { constructor() { } }

Suggest An Answer

No suggestions avaliable!

Latest post from Angular 2 Interview Questions

Ask Question