Questions tagged angular2-changedetection

Explore the latest questions and answers asked by our top developers.

changing html input element value in component’s ngAfterViewInit doesn’t trigger change detecion error

If I use viewChild on a html input element and change it’s value in the component’s afterViewInit lifecycle hook, it doesn’t trigger Angular’s content changed after checked change detection error. Why doesn’t Angular throw the error in this case? Source: Angular Questions

What’s the best for performance in onPush: detectChanges or markForCheck?

I have onPush strategy in my component. And I need to decide what changeDetectionRef I should use: I’ve read markForCheck() checks for every parent component up to the root. But detectChanges() run change detection once for the current component and all its children. In this code: this.datafeed.example.pipe(takeUntil(this.destroyer$)).subscribe(books => { this.books = books; this.cdr.detectChanges(); // or […]

With OnPush change detection strategy child component is updated from the parent anyway [duplicate]

In my child (NavBarComponent) and parent(HeaderComponent) components I’m using changeDetection: ChangeDetectionStrategy.OnPush. When I change totally separated components that in no way are connected to my components, without any @Input(), my components begin to run the ngDoCheck() method. My components are not even close in hierarchy to component I manually change(I change field from form), they […]

Angular 2 Lifecycle Hooks, change detection and ngZone

I have an Angular app where the user presses a button and trigger an animation. Basically it’s two pictures switching with each other to create a running illusion. At first my character is still then as we start to play, its pictures animate, but as it animates I get: ExpressionChangedAfterItHasBeenCheckedError My html: <img [src]="isPlaying == […]

Problems with Form using ngDoCheck()

I encountered a problem and created this simple illustration of my problem: I have a form to edit products, which have a name, category and price. I have 2 hardcoded products and 2 buttons, ‘load product one’ and ‘load product two’. When I click ‘load product one’, edit the product, and then save it (shown […]

createEmbeddedView creates view outside of changeDetection

I have a template and set of context to populate templates with. Done this a few times now but after an unknown change (that I am not able to backtrack…), change detection stopped working out of the box. I do not know what to do whit this I have tried multiple common fixes, but to […]

Change detection for child property in Angular

I have the following Product object inside an Angular application. The product contains array of orders and other product information. Product.ts export interface Product { ProductID: number; ProductName: string; Orders: Order[] } I need to display product information and generate order summary inside a child angular component. order-summary.component.ts export class OrderSummary { _product: Product; @Input() […]

Angular 11 change detection issue

I have a situation on my html view where I’m updating the material slider’s binding as follows: <mat-slider [disabled]="isLoading || (isUpdating$ | async)" color="primary" min="0" max="100" step="1" [ngModel]="myService.thresholdvalue$ | async" (change)="maskChanged($event)" ></mat-slider> But when my CHILD COMPONENT calls a service to update it via this.thresholdValueSub.next(value);, I’m getting the classic change detection error: ERROR Error: NG0100: […]

Angular changedetection not working with subject

I have a list of todo’s which I need to update whenever a todo is added or finished. The UI updates perfectly without my subject, but when I want to use a subject (which gets a new value when the database has changed), it doesn’t update. //Initial loading of all the todos this.todos = await […]

Angular: ChangeDetection Interferes with HostBinding

I’m trying to implement an Animate On Scroll library/helper based on this idea Wizdm Genesys I have a service that emits an IntersectionInfo (IsIntersecting, Direction, IsEntering, etc. ) object when an element intersects with the viewport. I subscribe to it and if the element is entering the viewport, I trigger the enter animation. It works […]

1 5

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq