Overview
TheFlightsFilterMenuComponent provides a Material Design menu with filtering controls for the flights list. Users can filter flights by airline operator and by flight state (all/flying/on ground). The component integrates with the FlightsStoreService to reactively update the displayed flights.
Selector: app-flights-filter-menu
Location: src/app/features/flights/ui/flights-filter-menu/flights-filter-menu.component.ts:15
Component API
Inputs
This component has no@Input() properties. It’s a standalone filter UI that communicates directly with the FlightsStoreService.
Outputs
This component has no@Output() events. Filter changes are automatically synchronized to the store service.
Store Integration
The component injects and uses theFlightsStoreService to:
- Read operator list:
store.operatorList()- Provides the list of unique operators - Update filters:
store.updateFilters()- Applies user-selected filters
filterForm.valueChanges and immediately updates the store, which triggers computed signal recalculation in the store’s filteredFlights computed property.
Source: flights-filter-menu.component.ts:31-51
Filter Form Structure
The component uses a reactive form with two controls:flights-filter-menu.component.ts:35-38
Operator Filter
- Control Type:
FormControl<string[] | null> - Default:
[''](all operators) - Behavior: Single-selection list (despite array type,
[multiple]="false"in template) - Options:
- “All” (empty string)
- Dynamic list from
store.operatorList()
Ground Status Filter
- Control Type:
FormControl<'all' | 'flying' | 'onGround'> - Default:
'all' - Options:
'all'- Show all flights'flying'- Show only airborne flights'onGround'- Show only grounded aircraft
Form Change Handling
On initialization, the component subscribes to form changes:- Automatically unsubscribes on component destroy using
takeUntilDestroyed - Extracts first operator from array (converts multi-select to single value)
- Null/undefined safety with fallback values
- Directly updates store filters
flights-filter-menu.component.ts:40-52
Template Structure
The component renders a Material menu triggered by a button:Menu Trigger
Operator Selection
- Shows count of available operators
- Scrollable list container
- “All” option to clear filter
- Dynamic operator options from store
- Prevents menu close on click with
stopPropagation()
Ground Status Toggle
- Radio button group for exclusive selection
- Three mutually exclusive states
- Prevents menu close on click
Usage Examples
In Flights Shell
In Flights List
Standalone Usage
Store Filter Application
When filters change, the store’sfilteredFlights computed signal automatically recalculates:
-
Operator Filter:
- Empty string or null = show all
- “Other” = show flights with null/empty operator
- Specific operator = exact match
-
Ground Status Filter:
'all'= no filtering'flying'= only flights withonGround === false'onGround'= only flights withonGround === true
Dependencies
-
Material Modules:
MatIconModule- Filter iconMatMenuModule- Dropdown menuMatListModule- Operator selection listMatRadioModule- Ground status radio buttonsMatFormFieldModule- Form field stylingMatSelectModule- Select componentMatButtonModule- Menu trigger button
-
Angular Modules:
ReactiveFormsModule- Form controls@angular/core/rxjs-interop- Auto-unsubscribe helper
-
Services:
FlightsStoreService- State management and filter application
Features
- Zero-configuration standalone component
- Reactive form with automatic store synchronization
- Dynamic operator list from current flights
- Prevents accidental menu closure during interaction
- Automatic cleanup on destroy
- Type-safe filter values
- Material Design styling
- Accessible ARIA labels
