From the course: Angular: API Communication and Authentication

Unlock the full course today

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

Using @angular/http to retrieve contacts, part 1

Using @angular/http to retrieve contacts, part 1 - Angular Tutorial

From the course: Angular: API Communication and Authentication

Start my 1-month free trial

Using @angular/http to retrieve contacts, part 1

- [Instructor] Now that we have the get route in our API we are ready to fetch this data, and render our contacts in our UI. Let's go ahead and open up the app.module.ts file, which is in client app. When working with HTTP in angular be sure to import the HTTP module from angular HTTP, and include it in imports of the NgModule. In our client folder open up app-routing.module.ts. We are currently defining two routes, a root route and a contacts route. The root route has an empty path, and we are telling angular that if this is requested to redirect to the contacts route. The contacts route will then render the contact list component. In this component we will fetch the data in order to render a list of contact components. Let's first import a couple of classes from angular HTTP. We will need HTTP, response, from angular HTTP. We will also need the contact model. That was contact and that is in the shared folder. The contact model is simply an interface describing the objects that we…

Contents