import { Component, inject, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms'
import { BookService } from '../services/book.service';
import { Book } from '../models/book';
import { BookdetailsComponent } from '../bookdetails/bookdetails.component';

@Component({
  selector: 'app-books',
  standalone: true,
  imports: [BookdetailsComponent, FormsModule],
  templateUrl: './books.component.html',
  styleUrl: './books.component.css'
})
export class BooksComponent implements OnInit {
  private bookService = inject(BookService)

  ngOnInit(): void {
    this.allBooks = this.bookService.getAllBooks()
  }

  allBooks: Book[] = []

  searchParam = ""

  /*passParam2FromHTMLToTs(paramValue: string){
    alert(paramValue)
  }*/

  searchBooks(){
    this.allBooks = this.bookService.findBooks(this.searchParam)
  }
}
