In this video we are going to learn about Service.
An Angular service is a stateless object and provides some very useful functions.
These functions can be invoked from any component of Angular, like Controllers, Directives, etc.
This helps in dividing the web application into small, different logical units which can be reused.
Alright now lets see how can we use services in angular 10.
First of all lets create service.
For that switch to the command prompt and run the command.

ng g service g user

Alright service has been created.
Now switch to the project and inside the app directory.
You can see the user.service.ts.
Inside this user.service.ts file and create a function.

return [

Now save this service file and lets use this service into the component.
For that just go to the app.component.ts file and her just import the service first.

import {UsersService} from './users.service';

Now create a property and inside the constructor just write as following.

user = null;
constructor(private user:UsersService){
this.users = this.user.getAllUsers();

Now lets print the user on html.
So just open app.component.html file and here write the following code.

<h2>All Users</h2>
<tr *ngFor=\"let user of Users\">

Alright all done so lets check this.
So switch to the browser and you can see the all user.
So in this way use service in angular 10.