From the course: Building Angular and ASP.NET Web API Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Adding a service

Adding a service

From the course: Building Angular and ASP.NET Web API Apps

Start my 1-month free trial

Adding a service

- [Instructor] In applications, most of the times, we need to use the same dataset across different components. So, it doesn't make sense to write the same code over and over again. Services help us achieve that. With services we can access methods and properties across other components in the entire project. And we are going to create a service named Entry Service, which we are going to use to call the http end points in our web API. But, how can we create a service using the Angular CLI. To create the service using the Angular CLI, right click over here, then go to Open In Terminal, and then type ng g, which stands for generate, and then service. Now, you can either write service in here, or just s, which stands for service, and then define the name of your service, which in our case, it's going to be entry, and press Enter to create the service. So, the service was created and you are going to see that we have two files. If you go inside the source folder, and then inside the app…

Contents