Guest User

Untitled

a guest
Apr 4th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { NavController } from 'ionic-angular';
  3.  
  4. export interface Result{
  5. title: string;
  6. author : string;
  7. date : string;
  8. image: string;
  9. };
  10.  
  11. const fakeResults: Result[] = [{
  12. "title": "Sweetest Thing, The",
  13. "author": "Guenevere Glasscott",
  14. "date": "6/1/2017",
  15. "image": "http://dummyimage.com/246x204.jpg/5fa2dd/ffffff"
  16. }, {
  17. "title": "Little Colonel, The",
  18. "author": "Penny McGrowther",
  19. "date": "3/17/2018",
  20. "image": "http://dummyimage.com/181x170.png/ff4444/ffffff"
  21. }, {
  22. "title": "Parenti serpenti",
  23. "author": "Blinny Earie",
  24. "date": "8/4/2017",
  25. "image": "http://dummyimage.com/219x171.jpg/dddddd/000000"
  26. }, {
  27. "title": "Only God Forgives",
  28. "author": "Boonie Peaple",
  29. "date": "8/4/2017",
  30. "image": "http://dummyimage.com/234x164.bmp/5fa2dd/ffffff"
  31. }, {
  32. "title": "Willow Creek",
  33. "author": "Kirbie Sterman",
  34. "date": "1/10/2018",
  35. "image": "http://dummyimage.com/189x173.bmp/ff4444/ffffff"
  36. }, {
  37. "title": "Easy A",
  38. "author": "Clo Pye",
  39. "date": "9/5/2017",
  40. "image": "http://dummyimage.com/182x157.jpg/cc0000/ffffff"
  41. }, {
  42. "title": "Tom Sawyer",
  43. "author": "Costanza Von Der Empten",
  44. "date": "11/1/2017",
  45. "image": "http://dummyimage.com/176x155.jpg/ff4444/ffffff"
  46. }, {
  47. "title": "A Good Marriage",
  48. "author": "Fidel Orneles",
  49. "date": "4/16/2017",
  50. "image": "http://dummyimage.com/151x160.png/dddddd/000000"
  51. }, {
  52. "title": "Dr. Giggles",
  53. "author": "Angeline Djekovic",
  54. "date": "9/16/2017",
  55. "image": "http://dummyimage.com/242x245.jpg/5fa2dd/ffffff"
  56. }, {
  57. "title": "Wuthering Heights",
  58. "author": "Joseito Iannini",
  59. "date": "1/24/2018",
  60. "image": "http://dummyimage.com/191x188.png/cc0000/ffffff"
  61. }];
  62.  
  63. @Component({
  64. selector: 'page-home',
  65. templateUrl: 'home.html'
  66. })
  67.  
  68. export class HomePage {
  69. results : Result[];
  70. filteredResults: Result[];
  71.  
  72. constructor(public navCtrl: NavController) {
  73. this.results = fakeResults;
  74. this.filteredResults = fakeResults;
  75. }
  76.  
  77. getItems(ev: any){
  78. let val = ev.target.value;
  79.  
  80. //Non empty string
  81. if (val && val.trim() != '') {
  82. this.filteredResults = this.results.filter((item) => {
  83. return (item.title.toLowerCase().indexOf(val.toLowerCase()) > -1);
  84. })
  85. }
  86. else{
  87. this.filteredResults.length = 0;
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment