This Lesson is for PRO Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Register a Service to Angular’s Dependency Injection Mechanism

Given that services are simple classes we could just import them in our component via normal ES2015 import statements and then instantiate them accordingly.

However, a service might depend upon other services as well and we definitely don’t want to manually wire up the entire chain of such dependencies. That’s why we have the dependency injector in Angular which will do it for us.

In this lesson we learn how to wire up our service properly by defining a provider that creates our service. We will also see how services defined on NgModule are globally visible because they are hooked up onto Angular’s root injector.

Please take a moment to tell your friends:

You must be a PRO Member to view code