import { Injectable } from '@angular/core';
import { Book } from '../models/book';

@Injectable({
  providedIn: 'root'
})
export class BookService {

  constructor() { }

  getAllBooks(): Book[]{
    return [
      {name: "Book1", writer: "zika", pages: 123},
      {name: "Book2", writer: "pera", pages: 32}
    ]
  }

  findBooks(searchParam: string): Book[]{
    return this.getAllBooks().filter(book=>
      book.name.includes(searchParam))
  }
}
