# new HeaderComponent()
The HeaderComponent provides a consistent header across the application with configurable elements such as title, back button, menu button, and CRUD operation controls. It extends NgxBaseComponent to inherit common functionality and implements OnInit for initialization logic. This component is designed to be flexible and adaptable to different page contexts, supporting various navigation patterns and visual styles.
Header component for application pages.
- Implements:
- OnInit
View Source app/components/header/header.component.ts, line 16
Extends
Classes
- HeaderComponent
Initializes a new HeaderComponent by calling the parent class constructor with the component name for logging and identification purposes.
- NgxBaseComponent
Initializes a new instance of the base component with the provided instance token. This constructor sets up the fundamental properties required by all Decaf components, including the component name, locale settings, and logging capabilities. The instance token is used for component identification and locale derivation.
The constructor performs the following initialization steps:
- Sets the componentName from the provided instance token
- Derives the componentLocale from the class name using utility functions
- Initializes the logger instance for the component
- HeaderComponent
Initializes a new HeaderComponent by calling the parent class constructor with the component name for logging and identification purposes.
Members
DecafRepository.<Model>
# protected _repository
Provides a connection to the data layer for retrieving and manipulating data.
This is an instance of the DecafRepository
class from the @decaf-ts/core
package,
which is initialized in the repository
getter method.
The repository is used to perform CRUD (Create, Read, Update, Delete) operations on the data model, such as fetching data, creating new items, updating existing items, and deleting items. It also provides methods for querying and filtering data based on specific criteria.
The repository for interacting with the data model.
- Inherited From:
Color
# backButtonColor
Sets the color of the back button icon using Ionic's predefined color palette. This allows the back button icon to match the application's color scheme.
Color of back button icon.
string
|
FunctionLike
# backButtonLink
Specifies a custom URL or function to execute when the back button is clicked. This overrides the default behavior of navigating to the previous page in history.
Custom navigation target for the back button.
Color
# backgroundColor
Sets the background color of the header using Ionic's predefined color palette. This allows the header to match the application's color scheme.
Background color of the header.
- Default Value:
- "primary"
View Source app/components/header/header.component.ts, line 516
StringOrBoolean
# border
When set to true, the header will display a border at the bottom. Setting to false removes the border for a more seamless design.
Controls whether the header has a border.
- Default Value:
- true
View Source app/components/header/header.component.ts, line 483
'start'
|
'end'
# buttonMenuSlot
Determines whether the menu button appears at the start or end of the header. This allows for customization of the header layout based on design requirements.
Position of the menu button in the header.
- Default Value:
- 'start'
View Source app/components/header/header.component.ts, line 430
StringOrBoolean
# center
When set to true, the header content (title, buttons) will be centered horizontally. This affects the overall layout and appearance of the header.
Controls whether the header content is centered.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 549
string
# className
Allows custom CSS classes to be added to the component's root element. These classes are appended to any automatically generated classes based on other component properties. Multiple classes can be provided as a space-separated string. This provides a way to customize the component's appearance beyond the built-in styling options.
Additional CSS class names to apply to the component.
- Overrides:
- Default Value:
- ""
ElementRef
# component
Provides direct access to the native DOM element of the component through Angular's ViewChild decorator. This reference can be used to manipulate the DOM element directly, apply custom styles, or access native element properties and methods. The element is identified by the 'component' template reference variable.
Reference to the component's element.
- Inherited From:
string
# componentLocale
Stores the automatically derived locale based on the component's class name. This is determined during component initialization and serves as a fallback when no explicit locale is provided via the locale input property. The derivation is handled by the getLocaleFromClassName utility function, which extracts a locale identifier from the component's class name.
The locale derived from the component's class name.
string
# protected componentName
Stores the name of the component, which is typically derived from the class name. This property is used internally for various purposes such as logging, deriving the default locale, and potentially for component identification in debugging or error reporting.
The componentName
is set during the component's initialization process and should not
be modified externally. It's marked as protected to allow access in derived classes while
preventing direct access from outside the component hierarchy.
The name of the component.
- Inherited From:
Example
// Inside a derived component class
console.log(this.componentName); // Outputs: "MyCustomComponent"
operations
# currentOperation
Indicates which CRUD operation is currently active. This affects the UI state and which operation buttons are highlighted or disabled.
The current CRUD operation being performed.
- Default Value:
- OperationKeys.READ
View Source app/components/header/header.component.ts, line 406
StringOrBoolean
# expand
When set to true, the header will expand vertically to fill available space. This can be useful for creating larger headers with more content.
Controls whether the header expands to fill available space.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 462
boolean
# initialized
Tracks whether the component has completed its initialization process. This flag is used to prevent duplicate initialization and to determine if certain operations that require initialization can be performed.
Flag indicating if the component has been initialized
- Overrides:
- Default Value:
- false
Record.<string, unknown>
# item
Defines how list items should be rendered in the component. This property holds a configuration object that specifies the tag name and other properties needed to render list items correctly. The tag property identifies which component should be used to render each item in a list. Additional properties can be included to customize the rendering behavior.
Configuration for list item rendering
- Inherited From:
- Default Value:
- {tag: ""}
EventEmitter.<RendererCustomEvent>
# listenEvent
Emits custom events that occur within child components or the layout itself. This allows parent components to listen for and respond to user interactions or state changes within the grid layout. Events are passed up the component hierarchy to enable coordinated behavior across the application.
Event emitter for custom renderer events.
- Inherited From:
string
# locale
Specifies the locale identifier to use when translating component text. This can be set explicitly via input property to override the automatically derived locale from the component name. The locale is typically a language code (e.g., 'en', 'fr') or a language-region code (e.g., 'en-US', 'fr-CA') that determines which translation set to use for the component's text content.
The locale to be used for translations.
- Inherited From:
string
# logo
When provided, displays a logo image in the header instead of or alongside the title text. This can be used for branding purposes.
URL or path to the logo image.
- Default Value:
- ""
View Source app/components/header/header.component.ts, line 451
Record.<string, string>
# mapper
Defines how fields from the data model should be mapped to properties used by the component. This allows for flexible data binding between the model and the component's display logic.
Field mapping configuration.
- Inherited From:
Color
# mobileBackgroundColor
Sets a different background color for the header when viewed on mobile devices. This allows for responsive design adjustments based on screen size.
Background color of the header on mobile devices.
- Default Value:
- ""
View Source app/components/header/header.component.ts, line 527
'start'
|
'end'
# mobileButtonMenuSlot
Determines whether the menu button appears at the start or end of the header when viewed on mobile devices. This allows for responsive layout adjustments.
Position of the menu button on mobile devices.
- Default Value:
- 'end'
View Source app/components/header/header.component.ts, line 538
"ios"
|
"md"
|
undefined
# mode
Controls the visual appearance of the component based on platform design guidelines. The 'ios' mode follows iOS design patterns, while 'md' (Material Design) follows Android/Google design patterns. This property affects various visual aspects such as animations, form elements, and icons. Setting this property allows components to maintain platform-specific styling for a more native look and feel.
Component platform style.
- Inherited From:
- Default Value:
- "md"
Model
|
undefined
# model
The data model repository that this component will use for CRUD operations. This provides a connection to the data layer for retrieving and manipulating data.
Repository model for data operations.
- Inherited From:
Array
# operations
Defines which CRUD operations (Create, Read, Update, Delete) are available for this component. This affects which operations can be performed on the data.
Available CRUD operations for this component.
- Inherited From:
- Default Value:
- [OperationKeys.READ]
string
# pk
Specifies which field in the model should be used as the primary key. This is typically used for identifying unique records in operations like update and delete.
Primary key field name for the model.
- Inherited From:
- Default Value:
- 'id'
Record.<string, unknown>
# props
Contains key-value pairs of dynamic properties that can be applied to the component at runtime. This flexible configuration object allows for dynamic property assignment without requiring explicit input bindings for every possible configuration option. Properties from this object are parsed and applied to the component instance through the parseProps method, enabling customizable component behavior based on external configuration.
Dynamic properties configuration object.
- Inherited From:
- Default Value:
- {}
string
|
StringOrBoolean
# renderChild
Determines if child components should be rendered by the component. This can be set to a boolean value or a string that can be converted to a boolean. When true, child components defined in the model will be rendered. When false, child components will be skipped. This provides control over the rendering depth.
Controls whether child components should be rendered
- Inherited From:
- Default Value:
- true
string
# rendererId
A unique identifier used to reference the component's renderer instance. This can be used for targeting specific renderer instances when multiple components are present on the same page.
Unique identifier for the renderer.
- Inherited From:
NgxRenderingEngine
# renderingEngine
Provides access to the NgxRenderingEngine singleton instance, which handles the rendering of components based on model definitions. This engine is used to extract decorator metadata and render child components.
Reference to the rendering engine instance
string
# route
Defines the base route path used for navigation actions related to this component. This is often used as a prefix for constructing navigation URLs.
Base route for navigation related to this component.
- Inherited From:
StringOrBoolean
# showBackButton
When set to true, the component will display a back button that allows users to navigate to the previous page. This is particularly useful for multi-level navigation flows.
Controls whether the back button is displayed.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 495
StringOrBoolean
# showMenuButton
When set to true, the component will display a menu button that can be used to toggle the application's side menu. This is particularly useful for mobile applications or any interface that uses a slide-in menu for navigation. The menu controller is automatically enabled/disabled based on this property.
Controls whether the menu button is displayed.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 419
string
# title
Sets the main title text that appears in the center of the header. This typically represents the name of the current page or section.
The title text displayed in the header.
string
# titleAligment
Specifies how the title text should be aligned within the header. Common values include 'start', 'center', and 'end'.
Controls the alignment of the title text.
StringOrBoolean
# translatable
Controls whether the component's text content should be processed for translation. When true, the component will attempt to translate text using the specified locale. When false, text is displayed as-is without translation. This property accepts either a boolean value or a string that can be converted to a boolean (e.g., 'true', 'false', '1', '0').
Determines if the component should be translated.
- Inherited From:
- Default Value:
- false
StringOrBoolean
# translucent
When set to true, the header will have a translucent appearance, allowing content behind it to be partially visible. This creates a modern, layered UI effect.
Controls whether the header has a translucent effect.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 561
string
|
number
# uid
A unique identifier for the current record being displayed or manipulated. This is typically used in conjunction with the primary key for operations on specific records.
Unique identifier for the current record.
- Inherited From:
Color
# static backButtonColor
Sets the color of the back button icon using Ionic's predefined color palette. This allows the back button icon to match the application's color scheme.
Color of back button icon.
string
|
FunctionLike
# static backButtonLink
Specifies a custom URL or function to execute when the back button is clicked. This overrides the default behavior of navigating to the previous page in history.
Custom navigation target for the back button.
Color
# static backgroundColor
Sets the background color of the header using Ionic's predefined color palette. This allows the header to match the application's color scheme.
Background color of the header.
- Default Value:
- "primary"
View Source app/components/header/header.component.ts, line 138
StringOrBoolean
# static border
When set to true, the header will display a border at the bottom. Setting to false removes the border for a more seamless design.
Controls whether the header has a border.
- Default Value:
- true
View Source app/components/header/header.component.ts, line 108
'start'
|
'end'
# static buttonMenuSlot
Determines whether the menu button appears at the start or end of the header. This allows for customization of the header layout based on design requirements.
Position of the menu button in the header.
- Default Value:
- 'start'
View Source app/components/header/header.component.ts, line 60
StringOrBoolean
# static center
When set to true, the header content (title, buttons) will be centered horizontally. This affects the overall layout and appearance of the header.
Controls whether the header content is centered.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 168
operations
# static currentOperation
Indicates which CRUD operation is currently active. This affects the UI state and which operation buttons are highlighted or disabled.
The current CRUD operation being performed.
- Default Value:
- OperationKeys.READ
View Source app/components/header/header.component.ts, line 38
StringOrBoolean
# static expand
When set to true, the header will expand vertically to fill available space. This can be useful for creating larger headers with more content.
Controls whether the header expands to fill available space.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 89
string
# static logo
When provided, displays a logo image in the header instead of or alongside the title text. This can be used for branding purposes.
URL or path to the logo image.
- Default Value:
- ""
View Source app/components/header/header.component.ts, line 79
Color
# static mobileBackgroundColor
Sets a different background color for the header when viewed on mobile devices. This allows for responsive design adjustments based on screen size.
Background color of the header on mobile devices.
- Default Value:
- ""
View Source app/components/header/header.component.ts, line 148
'start'
|
'end'
# static mobileButtonMenuSlot
Determines whether the menu button appears at the start or end of the header when viewed on mobile devices. This allows for responsive layout adjustments.
Position of the menu button on mobile devices.
- Default Value:
- 'end'
View Source app/components/header/header.component.ts, line 158
StringOrBoolean
# static showBackButton
When set to true, the component will display a back button that allows users to navigate to the previous page. This is particularly useful for multi-level navigation flows.
Controls whether the back button is displayed.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 119
StringOrBoolean
# static showMenuButton
When set to true, the component will display a menu button that can be used to toggle the application's side menu. This is particularly useful for mobile applications or any interface that uses a slide-in menu for navigation. The menu controller is automatically enabled/disabled based on this property.
Controls whether the menu button is displayed.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 50
string
# static title
Sets the main title text that appears in the center of the header. This typically represents the name of the current page or section.
The title text displayed in the header.
string
# static titleAligment
Specifies how the title text should be aligned within the header. Common values include 'start', 'center', and 'end'.
Controls the alignment of the title text.
StringOrBoolean
# static translucent
When set to true, the header will have a translucent appearance, allowing content behind it to be partially visible. This creates a modern, layered UI effect.
Controls whether the header has a translucent effect.
- Default Value:
- false
View Source app/components/header/header.component.ts, line 179
Methods
# async changeOperation(operation, idopt) → {Promise.<boolean>}
This method constructs a navigation URL based on the model page, the requested operation, and optionally a model ID. It then uses the router service to navigate to the constructed URL. This is typically used when switching between different CRUD operations on a model.
Navigates to a different operation for the current model.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
operation |
string
|
The operation to navigate to (e.g., 'create', 'read', 'update', 'delete') |
|
id |
string
|
<optional> |
Optional model ID to include in the navigation URL |
A promise that resolves to true if navigation was successful
Promise.<boolean>
# getLocale(translatable) → {string}
Determines which locale string to use for translation based on the translatable flag and available locale settings. This method first converts the translatable parameter to a boolean using the stringToBoolean utility function. If translatable is false, it returns an empty string, indicating no translation should be performed. If translatable is true, it checks for an explicitly provided locale via the locale property. If no explicit locale is available, it falls back to the componentLocale derived from the component's class name.
Gets the appropriate locale string based on the translatable flag and available locales.
Parameters:
Name | Type | Description |
---|---|---|
translatable |
StringOrBoolean
|
Whether the component should be translated |
The locale string to use for translation, or empty string if not translatable
string
# getModel(model) → {void}
Processes the provided model parameter, which can be either a Model instance or a string identifier. If a string is provided, it attempts to resolve the actual model from the injectables registry. After resolving the model, it calls setModelDefinitions to configure the component based on the model's metadata.
Resolves and sets the component's model
Parameters:
Name | Type | Description |
---|---|---|
model |
string
|
Model
|
The model instance or identifier string |
void
# getRoute() → {string}
Retrieves the route path for the component, generating one based on the model if no route is explicitly set. This method checks if a route is already defined, and if not, it creates a default route based on the model's constructor name. The generated route follows the pattern '/model/{ModelName}'. This is useful for automatic routing in CRUD operations.
Gets the route for the component
The route path for the component, or empty string if no route is available
string
# handleEvent(event) → {void}
Receives events from child renderer components and forwards them to parent components through the listenEvent output. This creates an event propagation chain that allows events to bubble up through the component hierarchy, enabling coordinated responses to user interactions across the layout structure.
Handles custom events from child components.
Parameters:
Name | Type | Description |
---|---|---|
event |
RendererCustomEvent
|
The custom event from a child component |
void
# initialize()
Performs one-time initialization of the component. This method checks if the component has already been initialized to prevent duplicate initialization. When called for the first time, it sets the initialized flag to true and logs an initialization message with the component name. This method is typically called during the component's lifecycle setup.
Initializes the component
# isAllowed(operation) → {boolean}
This method checks if an operation is included in the list of available CRUD operations and if it's not the current operation (unless the current operation is CREATE). This is used to enable/disable or show/hide operation buttons in the UI.
Determines if a specific operation is allowed in the current context.
Parameters:
Name | Type | Description |
---|---|---|
operation |
string
|
The operation to check |
True if the operation is allowed, false otherwise
boolean
# ngOnChanges(changes) → {void}
This Angular lifecycle hook is called when input properties change. It responds to changes in the model, locale, or translatable properties by updating the component's internal state accordingly. When the model changes, it calls getModel to process the new model and getLocale to update the locale. When locale or translatable properties change, it calls getLocale to update the translation settings.
Handles changes to component inputs
Parameters:
Name | Type | Description |
---|---|---|
changes |
SimpleChanges
|
Object containing changed properties |
void
# ngOnInit() → {void}
Sets up the component by processing boolean inputs, enabling/disabling the menu controller, and building the CSS class string based on the component's properties. This method prepares the component for user interaction by ensuring all properties are properly initialized.
Initializes the component after Angular first displays the data-bound properties.
void
# protected parseProps(instance) → {void}
This method iterates through the properties of the provided instance object and applies any matching properties from the component's props configuration to the component instance. This allows for dynamic property assignment based on configuration stored in the props object, enabling flexible component customization without requiring explicit property binding for every possible configuration option.
The method performs a safe property assignment by checking if each key from the instance exists in the props object before applying it. This prevents accidental property overwriting and ensures only intended properties are modified.
Parses and applies properties from the props object to the component instance.
Parameters:
Name | Type | Description |
---|---|---|
instance |
KeyValue
|
The component instance object to process |
void
# setModelDefinitions(model) → {void}
Extracts and applies configuration from the model's decorators to set up the component. This method uses the rendering engine to retrieve decorator metadata from the model, then configures the component's mapper and item properties accordingly. It ensures the route is properly set and merges various properties from the model's metadata into the component's configuration.
Configures component properties based on model metadata
Parameters:
Name | Type | Description |
---|---|---|
model |
Model
|
The model to extract configuration from |
- Overrides:
void
# trackItemFn(index, item) → {string|number}
Provides a tracking function for Angular's *ngFor directive to optimize rendering performance. This method generates unique identifiers for list items based on their index and content, allowing Angular to efficiently track changes and minimize DOM manipulations during list updates. The tracking function is essential for maintaining component state and preventing unnecessary re-rendering of unchanged items.
Tracks items in ngFor loops for optimal change detection.
Parameters:
Name | Type | Description |
---|---|---|
index |
number
|
The index of the item in the list |
item |
KeyValue
|
string
|
number
|
The item data to track |
A unique identifier for the item
string
|
number