O'Reilly logo

TypeScript: Modern JavaScript Development by Ivo Gabe de Wolff, Vilic Vane, Remo H. Jansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the forecast component

As a quick recap, the forecast widget will look like this:

Creating the forecast component

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required