TableComponent is a simple, performant component for displaying city data in a responsive table format. It uses Bootstrap styling and Angular’s default change detection.
Location
src/app/features/paginator/components/table/table.component.ts
Component Selector
Inputs
Array of city objects to display in the table. Each city object contains:
Configuration
The component is configured with:- Change Detection: Uses
ChangeDetectionStrategy.Defaultfor automatic change detection - Standalone: Configured as a non-standalone component (module-based)
Template Structure
The component template (table.component.html) renders a responsive Bootstrap table:
Features
Responsive Design
The table is wrapped in atable-responsive container that enables horizontal scrolling on smaller screens.
Hover Effects
Thetable-hover class adds hover effects to table rows for better user interaction.
Conditional Rendering
The tbody only renders when there are cities to display:Accessibility
Includes a<caption> element for screen readers: “List of cities”
Data Display
The table displays two columns:- Nombre (Name): The city name (
city.city) - Estado (State): The state name (
city.state)
city_dane_code, state_dane_code, and id, the table only displays the human-readable name fields.
Usage Example
Example with Sample Data
Integration with Pagination
The table component is typically used in conjunction with the pagination and filters components:Styling
The component uses Bootstrap classes for styling:table: Base table stylingtable-hover: Hover effect on rowstable-responsive: Responsive wrapperw-100: Full widthw-50: 50% column widthfw-bold: Bold font weighttext-uppercase: Uppercase text for headers