Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { NavController } from 'ionic-angular';
- export interface Result{
- title: string;
- author : string;
- date : string;
- image: string;
- };
- const fakeResults: Result[] = [{
- "title": "Sweetest Thing, The",
- "author": "Guenevere Glasscott",
- "date": "6/1/2017",
- "image": "http://dummyimage.com/246x204.jpg/5fa2dd/ffffff"
- }, {
- "title": "Little Colonel, The",
- "author": "Penny McGrowther",
- "date": "3/17/2018",
- "image": "http://dummyimage.com/181x170.png/ff4444/ffffff"
- }, {
- "title": "Parenti serpenti",
- "author": "Blinny Earie",
- "date": "8/4/2017",
- "image": "http://dummyimage.com/219x171.jpg/dddddd/000000"
- }, {
- "title": "Only God Forgives",
- "author": "Boonie Peaple",
- "date": "8/4/2017",
- "image": "http://dummyimage.com/234x164.bmp/5fa2dd/ffffff"
- }, {
- "title": "Willow Creek",
- "author": "Kirbie Sterman",
- "date": "1/10/2018",
- "image": "http://dummyimage.com/189x173.bmp/ff4444/ffffff"
- }, {
- "title": "Easy A",
- "author": "Clo Pye",
- "date": "9/5/2017",
- "image": "http://dummyimage.com/182x157.jpg/cc0000/ffffff"
- }, {
- "title": "Tom Sawyer",
- "author": "Costanza Von Der Empten",
- "date": "11/1/2017",
- "image": "http://dummyimage.com/176x155.jpg/ff4444/ffffff"
- }, {
- "title": "A Good Marriage",
- "author": "Fidel Orneles",
- "date": "4/16/2017",
- "image": "http://dummyimage.com/151x160.png/dddddd/000000"
- }, {
- "title": "Dr. Giggles",
- "author": "Angeline Djekovic",
- "date": "9/16/2017",
- "image": "http://dummyimage.com/242x245.jpg/5fa2dd/ffffff"
- }, {
- "title": "Wuthering Heights",
- "author": "Joseito Iannini",
- "date": "1/24/2018",
- "image": "http://dummyimage.com/191x188.png/cc0000/ffffff"
- }];
- @Component({
- selector: 'page-home',
- templateUrl: 'home.html'
- })
- export class HomePage {
- results : Result[];
- filteredResults: Result[];
- constructor(public navCtrl: NavController) {
- this.results = fakeResults;
- this.filteredResults = fakeResults;
- }
- getItems(ev: any){
- let val = ev.target.value;
- //Non empty string
- if (val && val.trim() != '') {
- this.filteredResults = this.results.filter((item) => {
- return (item.title.toLowerCase().indexOf(val.toLowerCase()) > -1);
- })
- }
- else{
- this.filteredResults.length = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment