source: trip-planner-front/src/app/explore/explore.component.ts@ b738035

Last change on this file since b738035 was b738035, checked in by Ema <ema_spirova@…>, 3 years ago

signup/login server errors on front and remove location from planner

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import { Component, OnInit } from '@angular/core';
2import { City } from '../_models/city';
3import { CityService } from '../_services/city.service';
4
5
6@Component({
7 selector: 'app-explore',
8 templateUrl: './explore.component.html',
9 styleUrls: ['./explore.component.css']
10})
11export class ExploreComponent implements OnInit {
12
13 cities: City[];
14 filteredCountries: any[];
15 text: string;
16 loading = [false, false, false, false];
17
18 constructor(private cityService: CityService) {
19 this.cities = [];
20 this.filteredCountries = [];
21 this.text = '';
22 }
23
24 ngOnInit(): void {
25 this.cityService.getAllCities().subscribe(
26 cities => {
27 this.cities = cities;
28 }
29 );
30 }
31
32 search(event) {
33 let filtered: any[] = [];
34 let query = event.query;
35 for (let i = 0; i < this.cities.length; i++) {
36 let city = this.cities[i];
37 if (city.name.toLowerCase().indexOf(query.toLowerCase()) == 0) {
38 filtered.push(city);
39 }
40 }
41 this.filteredCountries = filtered;
42 }
43
44 load(index) {
45 this.loading[index] = true;
46 setTimeout(() => this.loading[index] = false, 1000);
47 }
48}
Note: See TracBrowser for help on using the repository browser.