concept home - list component in category angular

appears as: home-list component, The home-list component
Getting MEAN with Mongo, Express, Angular, and Node.js 2ED

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.

When you added name = 'Costy' to the home-list component to try it out, for example, you should have added name: string = 'Costy' instead. This code would have told TypeScript that name should only ever be a string value.

You do the same when creating a variable or class member that’s an instance of a class, but in this case stating that the type is the name of the class. Listing 8.8 shows how to add a location class member with the type Location to the home-list component, giving it all the values it needs. The common way to describe this is to say that location is an instance of type Location.

In homepage.component.html, put the selector for the home-list component for a moment before checking it in the browser:

9.3.3. Using the geolocation service from the home-list component

The home-list component now has access to the geolocation service, so use it! Remember, your getPosition method in the service accepts three callback functions, so you’ll need to create those functions before you can call the method.