Overview
TheCatalogoComponent displays the complete catalog of available books to regular users. It allows users to browse books and request loans for available titles.
Component Metadata
app-catalogo
Imports:
CommonModule- Angular common directives
./catalogo.html
Properties
libros
id: Book identifiertitulo: Book titleportada: Cover image URLanioPublicacion: Publication yeardisponible: Availability statusgenero: Genre informationautores: Array of author information
loading
Injected Services
- LibroService - Fetches book data from the API
- PrestamoService - Handles loan requests
Lifecycle Hooks
ngOnInit
Methods
cargarLibros
LibroService:
- On success: Populates
librosarray and setsloadingtofalse - On error: Logs error to console and sets
loadingtofalse
solicitarPrestamo
- Displays confirmation dialog with book title
- If confirmed, calls
PrestamoService.solicitar()with the book ID - On success: Shows success alert informing user that admin will review the request
- On error: Shows error alert with the error message from the backend
libro- TheLibroobject for which to request a loan
Template Features
The component template displays books in a responsive card grid:Full Source Code
Related Components
- PrestamoListComponent - Admin view for managing loan requests
- LibroListComponent - Admin view for managing books
Related Services
- LibroService - Book data operations
- PrestamoService - Loan request operations
Related Models
- Libro - Book data structure