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

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

  constructor() { }

  getAllBooks(): Book[]{
    return [{name: "Knjiga 1", writer: "Petar Petrovic", pages: 115},
      {name: "Knjiga 2", writer: "Mirko Mirkovic", pages: 315},
      {name: "Knjiga 3", writer: "Petar Petrovic", pages: 65}
    ]
  }

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