Fetching Courses Created from the Database
Explore how to fetch courses stored in a database and display them in your Angular app by consuming REST APIs. Understand how to use Angular's *ngFor directive to loop through data and apply conditional styling based on course status.
We'll cover the following...
We'll cover the following...
In this lesson, we’ll display all the courses created and saved into the database on the client-side of our application. To do that, we need to take the following steps:
Step 1: Consuming the REST API
To consume the REST API to show a list of created courses, we head to the course-list directory and open the course-list.component.ts file. Next, we integrate the code below:
Below is a summary of the above code:
We start by importing CourseService in line 2.
- Next, we create a variable called
coursesin line 10