We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Load asynchonous data in templates

Hello,


I would like to customize schedule's quick infos template.

I saw that directive #quickInfoTemplatesContent and let-data which works fine when displaying data attributes.

But I need to perform a HTTP request to get some additionnal data to display in the template and I have some trouble.


Seems like the template refreshes continually even if nothing changes and subscribes to my HTTP request each time. The result is my async data is continually loading. The subscriptions are never unsubscribed.


See example on stackblitz: https://stackblitz.com/edit/angular-1uns36?file=app.component.html,app.component.ts,app%2Fapp.module.ts,content.txt


Do you have any idea?


Thanks for your response!


2 Replies 1 reply marked as answer

CC Carla Candiotti November 14, 2022 08:53 AM UTC

Hello,


Do someone have an idea?


Thanks



RV Ravikumar Venkatesan Syncfusion Team November 14, 2022 01:12 PM UTC

Angular doesn’t know whether the value returned from the methods bound to the template is changed or not. So, the Angular change detection calls the method bound to the template on each change detection. You can resolve the problem by setting up the changeDetection value as highlighted in the snippet.


Sample: https://stackblitz.com/edit/ej2-angular-schedule-quick-info-template-change-detectio?file=app.component.ts


[app.component.ts]

import { ComponentViewChildViewEncapsulationInjectChangeDetectionStrategy } from '@angular/core';

 

@Component({

  // tslint:disable-next-line:component-selector

  selector: 'app-root',

  templateUrl: 'app.component.html',

  styleUrls: ['app.component.css'],

  encapsulation: ViewEncapsulation.None,

  changeDetection: ChangeDetectionStrategy.OnPush

})

export class AppComponent {

}


If this post is helpful, consider accepting it as the solution so that other members can locate it more quickly.


Marked as answer
Loader.
Live Chat Icon For mobile
Up arrow icon