Category : angular2-changedetection

I have following Angular (v11) component containing a Material table with virtual scrolling: @Component({ selector: ‘app-table’, template: ` <cdk-virtual-scroll-viewport [itemSize]="50" class="wrapper mat-elevation-z2"> <table mat-table [dataSource]="items"> <!– Name Column –> <ng-container matColumnDef="name" [sticky]="isNameSticky"> <th mat-header-cell *matHeaderCellDef>Name</th> <td mat-cell *matCellDef="let item"> <button *ngIf="item.isExpandable" (click)="item.isLoading = true; runLongRunningScript(item); item.isLoading = false;"> <div class="button__icon"> <app-spinner [class.hide]="!task.isLoading"></ptrn-spinner> <app-icon-chevron-down [class.hide]="task.isExpanded || ..

Read more

I have realized after posting the question that the github link below is the exact same problem, but no definite solution is given. I’m writing an Angular app, using version 12. I opened up Angular devtools and found that I have ~150 change detection cycles each second, nonstop. It’s worth mentioning that it is an ..

Read more

I’m writing an Angular app, using version 12. I opened up Angular devtools and found that I have ~150 change detection cycles each second, nonstop. It’s worth mentioning that it is an ASP.NET Core WebAPI app, which comes with ApiAuthorizationModule that adds logic and elements regarding login, logout, navigation etc. I can’t prove it definitely, ..

Read more

what is the best approach to sharing data stored in a service to a component, while using the onpush strategy? since onpush strategy requires immutability ( which is what i want to use anyway ) I want to update an array stored on the service for example using the spread operator since it doesn’t mutate ..

Read more

My understanding of angular change detection strategy from various articles and stackoverflow posts: The change detection process includes: Updating inputs to children of a component. Run change detection for embedded views. Call ngOnChanges, ngDoCheck, ngOnInit on children if applicable. Update content children in current component. Call afterContentInit, afterContentChecked of children if applicable. Update DOM interpolation ..

Read more

Fellow developers, I’ve got a service that stores a FormArray, which is appended to by one component and viewed by a different component. Even though, the FormArray is immutable and being reassigned to, the view is not updating successfully. The issue goes away when not using OnPush change detection, or if change detection is force ..

Read more