Browse Source

feat(lib): replace ngOnChanges with effect

pull/6533/head
KenTandrian 3 weeks ago
parent
commit
e05d3d8d25
  1. 8
      libs/ui/src/lib/toggle/toggle.component.ts

8
libs/ui/src/lib/toggle/toggle.component.ts

@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
OnChanges,
effect,
input,
output
} from '@angular/core';
@ -18,7 +18,7 @@ import { MatRadioModule } from '@angular/material/radio';
styleUrls: ['./toggle.component.scss'],
templateUrl: './toggle.component.html'
})
export class GfToggleComponent implements OnChanges {
export class GfToggleComponent {
public readonly defaultValue = input.required<string>();
public readonly isLoading = input<boolean>(false);
public readonly options = input<ToggleOption[]>([]);
@ -26,8 +26,10 @@ export class GfToggleComponent implements OnChanges {
protected readonly optionFormControl = new FormControl<string | null>(null);
protected readonly valueChange = output<Pick<ToggleOption, 'value'>>();
public ngOnChanges() {
constructor() {
effect(() => {
this.optionFormControl.setValue(this.defaultValue());
});
}
public onValueChange() {

Loading…
Cancel
Save