Creating the forecast component
As a quick recap, the forecast widget will look like this:
What properties does the class need? The template will need forecast data of the current day or the next day. The component can show the weather of Today and Tomorrow, so we will also need a property for that. For fetching the forecast, we also need the location. To show the loading state in the template, we will also store that in the class. This will result in the following class, in lib/forecast.ts
:
import { Component, Input } from "angular2/core"; import { ForecastResponse } from "./api"; export interface ForecastData { date: string; temperature: number; ...
Get TypeScript: Modern JavaScript Development 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.