July 2017
Intermediate to advanced
454 pages
10h 1m
English
Now, you will learn how to register a provider in a component and use the injectable service class inside a component.
First, let's quickly generate a component and service using the Angular CLI ng command:
ng g component ./test-di
This will generate the component and the required files. The output of the command is shown in the following screenshot:

Now, we have to generate an Angular service in the same folder:
ng g service ./test-di
The output of the preceding command is as follows:

Read now
Unlock full access