From the course: Building Angular and ASP.NET Core Applications
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Reading data from Angular
From the course: Building Angular and ASP.NET Core Applications
Reading data from Angular
- Now that we have the HTML file ready, let us modify the DS file to read the data from the web API. For that we are going to first create a method in the Angular service. Then next we are going to inject this service in our component, then call the method from our component, and at the end, handle the response. Let's go to visual code and see this in action. In here, go to ClientApp, then source, app, and then services. In here open the book.service.ts file. Let us first define the base URL. And the base URL, which is of type string, is going to be api/books. For us to be able to send HTTP requests to our web API, we need to inject the HTTP client. So for that we write in here private http, and then httpClient. Now let us create a method to get all the books. For that, we just write in here getAllBooks, and then inside this method, we are going to return this.http. We want to send a get request, which is going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Angular key concepts2m 25s
-
(Locked)
Generating components and services4m 47s
-
(Locked)
Cleaning up code and updating the router7m 11s
-
(Locked)
Designing the Books page8m 10s
-
(Locked)
Reading data from Angular3m 39s
-
(Locked)
Designing the Create page9m 4s
-
(Locked)
Adding new data from Angular9m 50s
-
(Locked)
Designing the Book Details page7m 44s
-
(Locked)
Getting a single book from Angular3m 18s
-
(Locked)
Updating existing data from Angular9m 20s
-
(Locked)
Deleting data from Angular6m 45s
-
(Locked)
Handling errors in Angular12m 24s
-
-
-
-