From the course: Building Angular and ASP.NET Core Applications
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Getting a single book from Angular
From the course: Building Angular and ASP.NET Core Applications
Getting a single book from Angular
- [Instructor] Now that we have created the book details view, it's time to get the data from the Web API. For that, we are going to create a method in our service. Then we are going to inject this service in our component. And at the end, we are going to handle result. So, let's see this in action. In here, go to ClientApp, src, app, services, and then book.service.ts file. Here we are going to create a method which takes the parameter of book ID and then returns a book. So let's write in here, "getBookById, id, it's of type number. We are going to return this.http.get which is going to return a Book response, then this._baseURL. And then in here we write inside double quotes, /singleBook, then /, and we append in here the id. Let us save the changes and go to our component. So inside the components folder, go to show-book, then show-book.component.cs. Let us inject in here the service so we can use the method…
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
-
-
-
-