toggle/src/toggle/toggle.component.ts
<talenra-toggle> is an on/off control. Think of a checkbox (which the control
technically is), displayed as a toggle switch.
// Component class
sampleForm: FormGroup = new FormGroup({
rememberMe: new FormControl(true),
disabledToggle: new FormControl({ value: false, disabled: true }),
});<!-- Component template -->
<form [formGroup]="sampleForm">
<talenra-toggle formControlName="rememberMe" label="Remember me" />
<talenra-toggle formControlName="disabledToggle" label="Toggle (disabled)" />
</form>// Import `FormsModule` in the declaring module
import { FormsModule } from '@angular/forms';
@NgModule({
// ...
imports: [FormsModule],
})// Component class
sampleValue = true;<!-- Component template -->
<form #templateDrivenForm="ngForm">
<talenra-toggle name="sampleValue" [(ngModel)]="sampleValue" label="Sample value" />
</form>// Component class
sampleValue = true;<!-- Component template -->
<talenra-toggle [(ngModel)]="sampleValue" label="Sample value" />import { ToggleComponent } from '@talenra/components/toggle';
ControlValueAccessor
OnInit
AfterViewInit
| changeDetection | ChangeDetectionStrategy.OnPush |
| host | { |
| providers |
)
|
| selector | talenra-toggle |
| styleUrls | ./toggle.component.scss |
| templateUrl | ./toggle.component.html |
Inputs |
Outputs |
| checked |
Type : boolean
|
|
Determines whether the control is checked. Note: Typically the |
| value |
Type : boolean
|
|
The native element's value attribute. Setting the value will update the checked
state of the control ( Note: A native checkbox element's value and checked state do not neccessarily align.
However, the on-off-controls in this library (e.g. |
| label |
Type : string
|
Default value : ''
|
|
Label displayed to the user. |
| disabled |
Type : boolean
|
|
Determinates whether the control is en-/disabled. |
| formControlName |
Type : string
|
Default value : ''
|
|
Name of the corresponding |
| readonly |
Type : boolean, unknown
|
Default value : false, { transform: booleanAttribute }
|
|
Determines whether the control is readonly. |
| checkedChange |
Type : EventEmitter<ToggleChange>
|
|
Event emitted when the toggle's |