Questions tagged [angular2-changedetection]
473 questions
3
votes
1 answer
Update AsyncPipe when ChangeDetectorRef is detached
By looking at the way change detection is implemented in AsyncPipe, it seems like this._ref.markForCheck() doesn't run if ChangeDetectorRef is detached (as is also confirmed in here).
The motivation for this is to have full control over when the…

Daniel Shin
- 5,086
- 2
- 30
- 53
3
votes
1 answer
Angular2 Calling exposed method from outside app and loses change binding
I have a public method that I exposed to window. This method talks to a Component and modifies a variable I am watching in my template. But when I change the value, the *ngIf() does not get triggered.
app.component
constructor(private _public:…

Rob
- 11,185
- 10
- 36
- 54
3
votes
1 answer
Change Detection on Input Array
I am inputting an array of objects into a component that are generated from an HTTP request response (asynchronous), and I want to fill up a different array with just the first three array elements.
I want to fill up the new array at the same time…

Kevin LeStarge
- 8,142
- 4
- 21
- 34
3
votes
0 answers
Listening to variable change in a service in Angular2
What is the best way to listen to a variable change in Anuglar2 service. And on this change the component updates itself.

Ajey
- 7,924
- 12
- 62
- 86
3
votes
2 answers
Angular 1.x vs 2 Change detection performance
i 've been playing around with AngularJS 1.x and Angular 2, trying to compare their performance.
Here is a Plunkr showing a 'down-side' with Angular 1.x. If too many elements are present on the scope, you will notice lags in rendering the input…

Fjut
- 1,314
- 12
- 23
3
votes
2 answers
Angular2 detect changes using value equivalence or reference equality?
I am using Angular2-RC.1 and I have seen a poor performance when I setup a component having large data.
I have a tabular component (wrapping Handsontable) and I expose a bindable Input property called "data".
This property is usually bound to a…

Jairo Andres Velasco Romero
- 1,994
- 1
- 19
- 31
3
votes
2 answers
Does `changeDetection: ChangeDetectionStrategy.OnPush` in angular2 only works in one direction: top->bottom?
Consider this plunker
import {Component, OnInit, Input, OnChanges, DoCheck, ChangeDetectionStrategy, EventEmitter} from 'angular2/core'
@Component({
selector: 'child11',
template: `

testing
- 2,303
- 4
- 20
- 32
2
votes
0 answers
Why is it considered a code smell to call detectChanges()?
I recently reviewed some code where detectChanges is called. I've read all over the place that manually running a change detection cycle is a code smell and a sign that you are probably doing something wrong. I've personally never had to use it in…

Cory
- 51
- 2
2
votes
1 answer
Angular ChangeDetectionStrategy.OnPush & Observables not working within ngAfterViewInit hook
While using ChangeDetectionStrategy.OnPush observables$ that are updated within ngAfterViewInit on children components do not have their values reflected correctly within their respective html templates.
@Component({
selector: 'app-example',
…

Munerz
- 1,052
- 1
- 13
- 26
2
votes
1 answer
Angular infinite change detection loop caused by oidc-client library
I copied the solution people posted on github linked below, check it out for further comments by library creators, if they ever solve this.
I'm writing an Angular app, using version 12. I opened up Angular devtools and found that I have ~150 change…

dzenesiz
- 1,388
- 4
- 27
- 58
2
votes
1 answer
Why is Angular's ChangeDetection not triggered when using canvas.toBlob() with an arrow function?
I have a very simple component in Angular 10. When a form is submitted the Blob of an canvas-element is created and stored.
Therefor the releveant part of the onSubmit() function looks like this:
onSubmit(): void {
const canvas: HTMLCanvasElement…

lampshade
- 2,470
- 3
- 36
- 74
2
votes
1 answer
Long idle time on event clicks on Angular webapp
I have an Angular10 web application.
While analyzing the performance with DevTools I noticed that the click event takes quite a long time, most of it is spent doing nothing, then a globalZoneAwareCallback is called followed by a microtask
Here's a…

Gianluca Ghettini
- 11,129
- 19
- 93
- 159
2
votes
3 answers
changeDetection onPush is triggering only on second click
I found some issues with the performance regarding Change detection so I started using onPush from the past few weeks. Everything is fine till now but I donno its behaving weird with p-chips where its working only on second click :(
Stackblitz…

Gvs Akhil
- 2,165
- 2
- 16
- 33
2
votes
1 answer
What the difference between markDirty() and markForCheck()
With new Ivy compilation and rendering pipeline we also have a few new functions for working with change detector.
I'm interested in markDirty().
As far as I understand this function provides an ability to schedule change detection firing for a…

Alice Smith
- 81
- 1
- 9
2
votes
2 answers
DOM is getting updated for a view with OnPush strategy during change detection cycle even though Input is not changed
Perhaps I'm missing something in Change Detection mechanism in Angular.
I have 2 components:
AppComponent.
@Component({
selector: 'my-app',
template: `

fekaloid
- 195
- 1
- 2
- 9