Property initialization

In statically-typed languages such as Java, it is drilled into you that proper variable initialization/instantiation is the key to error free operation. So let's try that in CurrentWeatherComponent by initializing current with default values:

src/app/current-weather/current-weather.component.tsconstructor(private weatherService: WeatherService) {  this.current = {    city: '',    country: '',    date: 0,    image: '',    temperature: 0,    description: '',  }}

The outcome of these changes will reduce console errors from 12 to 3, at which point you will only be seeing API call related errors. However, the app itself will not be in a presentable state, as you can see below:

Results of Property Initialization

To make this view presentable ...

Get Angular 6 for Enterprise-Ready Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.