Injecting Service into another Service | Services & Dependency Injection | Angular 12+

Поділитися
Вставка
  • Опубліковано 21 лют 2022
  • In the beginning of this section we learned that we can use services to communicate between components, directives and service. We have already learned how to inject a service dependency to a component class.
    In this lecture, lets learn how to inject a service dependency into another service. This lecture is a continuation to the previous lecture.

КОМЕНТАРІ • 12

  • @jjuliefrance
    @jjuliefrance Рік тому +4

    Finally, here we are. You got there at the very end of this video. The @injectable decorator. However, it was good to watch the all process of your demo. Many thanks.

  • @khalidsultani1896
    @khalidsultani1896 Рік тому +2

    Thanks for posting the most clear and easy to undrestand explanation.

  • @annoor2024
    @annoor2024 Рік тому +2

    The best best best explanation I've ever watched.

  • @TheGuy797
    @TheGuy797 2 роки тому +2

    You explain everything real good! Thank you for the videos!

  • @OmPrakash-on3pk
    @OmPrakash-on3pk Рік тому +1

    Wow! excellent way......thanks a lot.

  • @maneshwar3054
    @maneshwar3054 Рік тому +6

    @Injectable({
    providedIn: 'root'
    })
    This is another way to inject the service into another service instead of providing in Component or App module. If you are creating the service through Angular CLI then by default, it will be added to the service.

  • @yurapekach7550
    @yurapekach7550 Рік тому

    Thank you so much!

  • @OutSystemsJourney2023
    @OutSystemsJourney2023 Рік тому +3

    I understood the concept you explain about Injecting a service into another service, but I didnt understand why you inject the logger service in the component? As I see you injected the logger service without any reason, as the component is not directly communicating with the logger service.

    • @maneshwar3054
      @maneshwar3054 Рік тому +3

      "component is not directly communicating with the logger service."
      User service requires instance of logger service to access the log method. Since, the Logger service is not provided in the app module, we need to provide in the component.

  • @akashsolanki5570
    @akashsolanki5570 6 місяців тому +1

    Why do we need to provide an instance of logger service separately in app.component.ts file, when logger service is not used in app.component.ts at all. Can't user service create a instance of logger service when user service's instance is created. and also it seems redundant.

    • @procademy
      @procademy  6 місяців тому +1

      Please watch sevices and dependency injection section of new Angular 16 playlist or there is a separate video I have created which covers this topic in depth. That might clear your doubt.