angular 应用程序中的手风琴数据未更新
Accordion data is not updating in angular application
我在 angular 应用程序中使用 Syncfusion 组件。我无法将更新的数据绑定到手风琴组件。
请在下面的 stackblitz link
中找到示例
在上面的代码中,如果我单击更改按钮,数据应该会更新,但手风琴中显示的是空数据。
请让我知道如何解决这个问题。
从 documentation 看来,您需要使用 AccordionComponent
中可用的 public 方法 addItem()
,您可以通过 [=12] 检索到该方法=].
希望对您有所帮助!
实际上我不喜欢文档中提到的方法,我认为它是用于将项目添加到现有手风琴中,而不是将其完全重新渲染为您的示例。
因为你有 *ngIf
指令有条件地显示它。我们可以像下面这样欺骗 angular 重新渲染它:
this.data1.length = 0;
setTimeout(() => {
this.data1 = this.count % 2 == 0 ? [...this.items] : [...this.items1];
});
参见 Stackblitz sample。
您应该使用 track by 来了解angular数据已更改。
*ngFor = "let item of data1;trackBy:identify"
identify(index,item){
return this.count;
}
我在 angular 应用程序中使用 Syncfusion 组件。我无法将更新的数据绑定到手风琴组件。 请在下面的 stackblitz link
中找到示例在上面的代码中,如果我单击更改按钮,数据应该会更新,但手风琴中显示的是空数据。 请让我知道如何解决这个问题。
从 documentation 看来,您需要使用 AccordionComponent
中可用的 public 方法 addItem()
,您可以通过 [=12] 检索到该方法=].
希望对您有所帮助!
实际上我不喜欢文档中提到的方法,我认为它是用于将项目添加到现有手风琴中,而不是将其完全重新渲染为您的示例。
因为你有 *ngIf
指令有条件地显示它。我们可以像下面这样欺骗 angular 重新渲染它:
this.data1.length = 0;
setTimeout(() => {
this.data1 = this.count % 2 == 0 ? [...this.items] : [...this.items1];
});
参见 Stackblitz sample。
您应该使用 track by 来了解angular数据已更改。
*ngFor = "let item of data1;trackBy:identify"
identify(index,item){
return this.count;
}