In the previous example I have demonstrated how we can make use of a service in a component.
Basically we injected a service into a company and there are many situations where we would like to
inject a service into a service.
So in this example that is what I want to demonstrate.
We want to use a service inside another set of.
So for this I go back to the same product which we created in the previous session and here I would
like to our longer service a service which is pretty common and I want to do some kind of logging through
it.
So it doesn't longer God sort as DOD see us.
So I have another ServiceNow.
Yes.
First let's get this out of this.
So I make this service also as indexable from Adelaide angle or Sly's called
Gloss Lauber And of course this is injectable.
And what should be there in the other service.
I would like to last brings.
So I will harp string and by for let's say this is empty there's nothing to look for.
Nothing here only we will provide one method called as log which is going to get as message ring and
of course that spring is going to be added to
the log logs and and maybe if required for them of us you can say.
So don't load the message
and that can be it is and this also is missing.
And it can be no return if required.
Maybe in log.
So I would like to get to
that said so I would like to control all the love message of suffering and only one message which we
are logging is also being put into the console this doc
smart loving Glenn.
OK.
So this is a service I'll call it a or longer service but it's recommended not compulsory the a longer
sort of service I would like to use in the employee's service which I have written here so wholly implosive
is get the reference.
Yes I'm going to write the constructor and construct up Alsip.
But I had log longer service.
So I don't know whether it was due in part to Section
good enough.
And now this is logwood is now a member because we have used the key word privately.
So can we use this in the method here.
Yes log on and up log some messages or something like felting employees and
as usual a common mistake like no point is which is longer service mention as indictable.
Yes we have done injectable here but Army indicating it is indictable are injecting any it for it to
be injected injected.
We need to market as a wider.
So when the market does provide little something like logger's out of this I would like to use it in
multiple components so we can we want to use it in multiple places within the more boom.
So I will market as a wider at the more level.
So your providers and providers are providing longer service
which our market
that's so advantage of mentioning in the provider section is hot anywhere within that we can inject
the longer small which we are doing in another service.
November in the service we don't have any decoding them.
When I wrote this this class does not have a decorator even though it does injectable.
There's no property called providers for this injectable.
If you are doing a component for component we have this but we don't have for service.
So right now we can't inject employees or was only in this component not anywhere else but because we
mentioned loggers servicing the providers property of indie module.
We can now use it globally anywhere in the project.
Again indirect luggers this no doesn't run the project
controller Fyffe
as well.
15 employees.
Would it might it for us.
I'll be getting that.
Letting employees
we're calling only 1 matter.
We don't have multiple methodes to go and demonstrate.
The other matter that we have done but is also involved there are multiple sodomizes multiple messages
are dead and at once we would like to print all of them.
So the only point which you have to remember is if a service has to use another service and I just look
at the module level in India more decorate that said otherwise you have to make the class indictable
and injected into the other service through a consumer.
Thank you.