Santhosh
Santhosh

Reputation: 1079

Accordion data is not updating in angular application

I am using Syncfusion components in my angular application. I am unable to bind the updated data to the accordion component. Please find the example in below stackblitz link

Sample

In the above code if I click the change button data should be updated but empty data is showing in accordion. Kindly let me know how to resolve this issue.

Upvotes: 0

Views: 534

Answers (3)

sajjad mousavi
sajjad mousavi

Reputation: 89

you should use track by to Understand angular that data is changed.

*ngFor = "let item of data1;trackBy:identify"

identify(index,item){
  return this.count;
 }

whatch this

Upvotes: 3

Eldar
Eldar

Reputation: 10790

Actually i don't like the method mentioned in the documents and i think it is for adding items to existing accordion not for re-rendering it entirely as your sample.

Since you have *ngIf directive to show it conditionally. We can trick angular to re-render it like below :

 this.data1.length = 0;
    setTimeout(() => {
      this.data1 = this.count % 2 == 0 ? [...this.items] : [...this.items1];   
    });

See Stackblitz sample.

Upvotes: 1

ahbon
ahbon

Reputation: 512

From the documentation, it appears that you need to use the public method addItem() available in the AccordionComponent that you can retrieve thanks to your @ViewChild.

Hope this helps!

Upvotes: 0

Related Questions