Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. {
  2. "resultCode": 1,
  3. "resultData": {
  4. "Itinary": [
  5. {
  6. "ItenaryFor": "Transfer",
  7. "Icon": "motel",
  8. "Comment": null,
  9. "Iscustomsave": true,
  10. "TourDelight": "Phi Phi Island, Phuket City Tour",
  11. "BackgroundImg": ""
  12. },
  13. {
  14. "ItenaryFor": "Sightseen",
  15. "Icon": "holiday",
  16. "Comment": null,
  17. "Iscustomsave": true,
  18. "TourDelight": "Phi Phi Island, Phuket City Tour",
  19. "BackgroundImg": ""
  20. },
  21. {
  22. "ItenaryFor": "Sightseen",
  23. "Icon": "holiday",
  24. "Comment": null,
  25. "Iscustomsave": true,
  26. "TourDelight": "Phi Phi Island, Phuket City Tour",
  27. "BackgroundImg": ""
  28. },
  29. {
  30. "ItenaryFor": "Hotel",
  31. "Icon": "motel",
  32. "Comment": null,
  33. "Iscustomsave": true,
  34. "TourDelight": "Phi Phi Island, Phuket City Tour",
  35. "BackgroundImg": ""
  36. },
  37. {
  38. "ItenaryFor": "Hotel",
  39. "Icon": "motel",
  40. "Comment": null,
  41. "Iscustomsave": true,
  42. "TourDelight": "Phi Phi Island, Phuket City Tour",
  43. "BackgroundImg": ""
  44. },
  45. {
  46. "ItenaryFor": "Hotel",
  47. "Icon": "motel",
  48. "Comment": null,
  49. "Iscustomsave": true,
  50. "TourDelight": null,
  51. "BackgroundImg": null
  52. },
  53. {
  54. "ItenaryFor": "Sightseen",
  55. "Icon": "holiday",
  56. "Comment": null,
  57. "Iscustomsave": true,
  58. "TourDelight": "Coral Island",
  59. "BackgroundImg": ""
  60. },
  61. {
  62. "ItenaryFor": "Hotel",
  63. "Icon": "motel",
  64. "Comment": null,
  65. "Iscustomsave": true,
  66. "TourDelight": "Coral Island",
  67. "BackgroundImg": null
  68. }
  69. ]
  70. }
  71. }
  72.  
  73. import { Component, OnInit } from '@angular/core';
  74.  
  75. import { IProduct } from './product';
  76. import { ProductService } from './product.service';
  77.  
  78. @Component({
  79. templateUrl: './product-list.component.html'
  80. })
  81. export class ProductListComponent implements OnInit {
  82.  
  83. _listFilter: string;
  84. get listFilter(): string {
  85. return this._listFilter;
  86. }
  87. set listFilter(value: string) {
  88. this._listFilter = value;
  89. this.filteredProducts = this.listFilter ? this.performFilter(this.listFilter) : this.products;
  90. }
  91.  
  92. filteredProducts: IProduct[];
  93. products: IProduct[] = [];
  94.  
  95. constructor(private _productService: ProductService) {
  96.  
  97. }
  98.  
  99. performFilter(filterBy: string): IProduct[] {
  100. filterBy = filterBy.toLocaleLowerCase();
  101. return this.products.filter((product: IProduct) =>
  102. product.productName.toLocaleLowerCase().indexOf(filterBy) !== -1);
  103. }
  104.  
  105. ngOnInit(): void {
  106. this._productService.getProducts()
  107. .subscribe(products => {
  108. this.products = products;
  109. this.filteredProducts = this.products;
  110. },
  111. error => this.errorMessage = <any>error);
  112. }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement