Ei kuvausta

floatlabeldemo.component.ts 1.9KB

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

Powered by TurnKey Linux.