From a8c6fd411cb2eb70b2b5a85468cacc2b5fccb04f Mon Sep 17 00:00:00 2001 From: Umanskiy Aleksey Date: Mon, 4 Nov 2024 15:41:57 +0200 Subject: [PATCH] refactor(accordion): introducing signals signals --- src/accordion/accordion.component.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/accordion/accordion.component.ts b/src/accordion/accordion.component.ts index a4ef7493ef..d62233c0f2 100644 --- a/src/accordion/accordion.component.ts +++ b/src/accordion/accordion.component.ts @@ -1,4 +1,4 @@ -import { Component, input, OnChanges, SimpleChanges } from '@angular/core'; +import { Component, effect, input } from '@angular/core'; import { AccordionPanelComponent } from './accordion-group.component'; import { AccordionConfig } from './accordion.config'; @@ -15,7 +15,7 @@ import { AccordionConfig } from './accordion.config'; }, standalone: true }) -export class AccordionComponent implements OnChanges { +export class AccordionComponent { /** turn on/off animation */ isAnimated = input(false); _isAnimated = this.isAnimated(); @@ -28,17 +28,11 @@ export class AccordionComponent implements OnChanges { constructor(config: AccordionConfig) { Object.assign(this, config); - } - - ngOnChanges(changes: SimpleChanges) { - if (changes['isAnimated'] && !changes['isAnimated'].firstChange) { - // Only update if foo has changed and isn't the initial setup + effect(() => { this._isAnimated = this.isAnimated(); - } - if (changes['closeOthers'] && !changes['closeOthers'].firstChange) { - // Only update if foo has changed and isn't the initial setup this._closeOthers = this.closeOthers(); - } + + }); } closeOtherPanels(openGroup: AccordionPanelComponent): void {