projects/ui-kit-lib/src/lib/v2/switch/switch.component.ts
OnInit
OnDestroy
ControlValueAccessor
| changeDetection | ChangeDetectionStrategy.Eager |
| encapsulation | ViewEncapsulation.None |
| host | { |
| providers |
)
MDSwitch
|
| selector | md-switch |
| styleUrls | ./switch.component.scss |
| templateUrl | ./switch.component.html |
Properties |
Methods |
Inputs |
Outputs |
HostListeners |
constructor()
|
| id |
Type : string
|
|
Host element id. Can be overridden by the consumer. |
| readonly |
Type : boolean | undefined
|
|
Read-only mode: prevents user interaction while still allowing focus. |
| tabindex |
Type : number | undefined
|
|
Keyboard tab order for the internal input. |
| disabled |
Default value : undefined, { transform: booleanAttribute }
|
|
Disabled input as a signal (explicit/external). |
| invalid |
Default value : undefined, { transform: booleanAttribute }
|
|
Optional "invalid" flag as a signalized input (used for UI state). |
| name |
Type : string | undefined
|
|
Optional control name (useful for forms & a11y attributes). |
| required |
Default value : undefined, { transform: booleanAttribute }
|
|
Optional "required" flag as a signalized input. |
| onChange |
Type : EventEmitter<ToggleSwitchChangeEvent>
|
|
Emits when the user toggles the switch via UI interaction. Example : |
| click | ||||||
Arguments : '$event'
|
||||||
click(event: MouseEvent)
|
||||||
|
Host click handler.
Parameters :
|
| _handleClick | ||||||||
_handleClick(event: Event)
|
||||||||
|
Centralized click logic:
Parameters :
Returns :
void
|
| checked |
checked()
|
|
Convenience getter for host class binding.
Returns :
any
Current checked state. |
| onBlur |
onBlur()
|
|
Focus-out handler (called from the template).
Returns :
void
|
| onFocus |
onFocus()
|
|
Focus-in handler (called from the template).
Returns :
void
|
| onHostClick | ||||||||
onHostClick(event: MouseEvent)
|
||||||||
Decorators :
@HostListener('click', ['$event'])
|
||||||||
|
Host click handler.
Parameters :
Returns :
void
|
| validate |
validate()
|
|
Synchronous validator hook (provided via
Returns :
void
|
| writeControlValue | ||||||||||||
writeControlValue(value: any, setModelValue: (value: any) => void)
|
||||||||||||
|
ControlValueAccessor: write an external value into the component.
Parameters :
Returns :
void
|
| registerOnChange | ||||||||
registerOnChange(fn: Function)
|
||||||||
|
CVA: registers the callback to propagate value changes to Angular Forms.
Parameters :
Returns :
void
|
| registerOnTouched | ||||||||
registerOnTouched(fn: Function)
|
||||||||
|
CVA: registers the callback to mark the control as touched.
Parameters :
Returns :
void
|
| setDisabledState | ||||||||
setDisabledState(val: boolean)
|
||||||||
|
CVA: enables/disables the control from the Forms API.
Parameters :
Returns :
void
|
| writeDisabledState | ||||||||
writeDisabledState(value: boolean)
|
||||||||
|
Programmatically set the internal disabled state (used by
Parameters :
Returns :
void
|
| writeModelValue | ||||||||
writeModelValue(value: any)
|
||||||||
|
Updates the internal value signal (
Parameters :
Returns :
void
|
| writeValue | ||||||||
writeValue(value: any)
|
||||||||
|
CVA: writes an external value into the control. Delegates to writeControlValue so children can customize behavior.
Parameters :
Returns :
void
|
| focused |
Type : boolean
|
Default value : false
|
|
Focus ring helper for template/styles. |
| input |
Type : ElementRef
|
Decorators :
@ViewChild('input')
|
|
Template reference to the internal input element (for focus management). |
| _disabled |
Type : unknown
|
Default value : signal<boolean>(false)
|
|
Internal disabled state set via CVA's |
| cd |
Type : unknown
|
Default value : inject(ChangeDetectorRef)
|
|
Change detector used by children to mark for check after updates. |
| modelValue |
Type : unknown
|
Default value : signal<string | string[] | any | undefined>(undefined)
|
|
Reactive internal value for the control (Signal). |
| onModelChange |
Type : Function
|
Default value : () => {...}
|
|
CVA onChange callback (assigned by Angular Forms). |
| onModelTouched |
Type : Function
|
Default value : () => {...}
|
|
CVA onTouched callback (assigned by Angular Forms). |