Nav apraksta

invalidstatedemo.component.ts 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {Component, OnInit} from '@angular/core';
  2. import {CountryService} from '../service/countryservice';
  3. import {AppBreadcrumbService} from '../../app.breadcrumb.service';
  4. @Component({
  5. templateUrl: './invalidstatedemo.component.html'
  6. })
  7. export class InvalidStateDemoComponent implements OnInit {
  8. countries: any[];
  9. cities: any[];
  10. filteredCountries: any[];
  11. value1: any;
  12. value2: any;
  13. value3: any;
  14. value4: any;
  15. value5: any;
  16. value6: any;
  17. value7: any;
  18. value8: any;
  19. value9: any;
  20. constructor(private countryService: CountryService, private breadcrumbService: AppBreadcrumbService) {
  21. this.breadcrumbService.setItems([
  22. {label: 'UI Kit'},
  23. {label: 'Invalid State', routerLink: ['/uikit/invalidstate']}
  24. ]);
  25. this.cities = [
  26. {name: 'New York', code: 'NY'},
  27. {name: 'Rome', code: 'RM'},
  28. {name: 'London', code: 'LDN'},
  29. {name: 'Istanbul', code: 'IST'},
  30. {name: 'Paris', code: 'PRS'}
  31. ];
  32. }
  33. ngOnInit() {
  34. this.countryService.getCountries().then(countries => {
  35. this.countries = countries;
  36. });
  37. }
  38. searchCountry(event) {
  39. // in a real application, make a request to a remote url with the query and return filtered results,
  40. // for demo we filter at client side
  41. const filtered: any[] = [];
  42. const query = event.query;
  43. for (let i = 0; i < this.countries.length; i++) {
  44. const country = this.countries[i];
  45. if (country.name.toLowerCase().indexOf(query.toLowerCase()) == 0) {
  46. filtered.push(country);
  47. }
  48. }
  49. this.filteredCountries = filtered;
  50. }
  51. }

Powered by TurnKey Linux.