Questions tagged [angular2-changedetection]

473 questions
4
votes
1 answer

Angular change detection: how to refresh only certain items?

Let's say I have 100 divs on my screen generated by *ngFor that takes values from my object that has data like {A1: someObject, A2: someOtherObject..., J10: someOtherOtherObject} I click on A1 and then on J10 and they switch their values. It…
4
votes
2 answers

Run Angular change detection only once and stop detecting changes for that component

I need to detect changes in angular only once when the component is loaded or when route has changed and i want to stop detecting changes after that. Actually I need to show and hide functionality depending on user role. So i have many *ngIf in a…
4
votes
2 answers

Angular 8 value won't update on view after change

I have a small component in Angular with a method that (for now) sets a timeout and changes the value of a variable. import { Component, ChangeDetectionStrategy } from '@angular/core'; @Component({ selector: 'my-component', templateUrl:…
4
votes
1 answer

Attempt to use a destroyed view: detectChanges event though the view is detached

I have a component which does some service calls, and gets promises. After Promises are resolved I am doing detectChanges. But sometimes the promises are being resolved when the component view is already destroyed, eg user closed tab (internal tab…
Narek Gevorgyan
  • 113
  • 1
  • 12
4
votes
3 answers

Force change detection in pipe (pure or impure) bound to ngModel

I'm binding an ngModel value to the angular percent pipe, updating on ngModelChange with updateOn set to blur. It works well except when entering the same value again. When entering the same value again, the pipe does not detect the change and the…
4
votes
1 answer

Angular: does it have an equivalent to ReactJS's "Reconciliation"?

After reading the documentations and a few articles about ReactJS and Angular's (not AngularJS) change detection and rendering phases, I've come to a question which I'll try to explain in a few moments. As you've probably read in React's docs (here…
GHB
  • 917
  • 6
  • 13
4
votes
1 answer

Angular 5 [hidden] not fully working

I'm testing an option to display/hide div based on boolean value from an observable. Based on the second answer provided from this stack question, I have the following code which collects the document body width and the returned value is used with a…
user3200548
  • 111
  • 1
  • 10
4
votes
1 answer

ExpressionChangedAfterItHasBeenCheckedError:Unable to detect

I have a angular 4 application. The app.component.html looks like this
Shruti Nair
  • 1,982
  • 8
  • 30
  • 57
4
votes
1 answer

Is it impossible for Angular 4+ to detect changes in Map?

I am passing a Map to a child component but when I set new key-value pair child component cannot detect it in ngOnChange but the first time it boot only. Is it a bug or simply not supported?
tom10271
  • 4,222
  • 5
  • 33
  • 62
4
votes
0 answers

Angular 4 View not updating after model change

I have drag and drop option with a tree structure, but all the nodes are made siblings due to some functionalities, So that we can make any node as parent. I am using Dragula ng2-dragula for drag and drop. If I drag a parent, I need to move all the…
Balaji Perumal
  • 830
  • 1
  • 6
  • 20
4
votes
3 answers

Angular change detection process repainting the dom

I'm learning about Angular change detection process and I'm checking the Chrome dev tools, I see strange behavior. My plnkr to demonstrate the behavior: http://plnkr.co/edit/cTLF00nQdhVmkHYc8IOu I have a simple component view:
  • 4
    votes
    1 answer

    Angular performance: component exposes public object with 500+ (sub-) members

    I am using angular 4 with Typescript. I have a static class with lots of public static/constant string members whose values will never change. This class is exposed on many of my components in order to have access to the members from the…
    PzYon
    • 2,963
    • 3
    • 16
    • 27
    4
    votes
    0 answers

    How can I trigger change detection from outside my angular2 app?

    I have an angular2 app. There is a service which is used in many components. This service provides a static method (which can be used from outside the angular app to update the value: class MyService { static _value: any; get value(): any…
    4
    votes
    0 answers

    ChangeDetectionStrategy OnPush - how to trigger change detection if the input is async

    Following are my undestanding on onPush change detection strategy. OnPush change detection is triggered if one of the following happens A bound event is received on the component. An input was updated. Async pipe received an event. Change detection…
    4
    votes
    0 answers

    Angular 2, change detection not working when occuring from within Observable

    let's say I have to following entity export class Photo { public data: Blob; public User: string; } the following component @Component({ template: '' }) export class…
    Arikael
    • 1,989
    • 1
    • 23
    • 60