May 2018
Intermediate to advanced
512 pages
11h 3m
English
Now, let's connect the new service method to the input field:
src/app/city-search/city-search.component.ts...export class CitySearchComponent implements OnInit { search = new FormControl() constructor(private weatherService: WeatherService) {} ... ngOnInit() { this.search.valueChanges .subscribe(...) }
We are treating all input as string at this point. The user input can be a city, zip code or a city and country code, or zip code and country code separated by a comma. While city or zip code is required, country code is optional. We can use the String.split function to parse any potential comma separated input and then trim any whitespace ...
Read now
Unlock full access