More form fields

Let's get hands-on and add the remaining form fields. After all, we can't book a flight by just supplying our names.

The from and to fields are going to be select boxes with a list of cities we can fly into and out of. This list of cities will be stored right in our component class, and then we can iterate over it in the template and render it as a select box:

export class FlightFormComponent implements OnInit {  flightModel: Flight;  // Array of cities  cities:Array<string> = [    'Lagos',    'Mumbai',    'New York',    'London',    'Nairobi'  ];  constructor() {    this.flightModel = new Flight('', '', '', '', 0, '', 0, 0, '');  }}

The array stores a few cities from around the world as strings. Let's now use the ngFor directive to iterate over ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.