Questions tagged [angular2-changedetection]
473 questions
4
votes
2 answers
Angular 2, Does @Input with a setter behave differently than @Input without a setter?
I am wondering if someone could elaborate on this. Does @Input() with a setter vs using @Input() without a setter behave differently in regards to change detection?
For example:
@Input() something: SomeType;
-vs-
private _something;
@Input() set…

khollenbeck
- 16,028
- 18
- 66
- 101
4
votes
2 answers
Why replacing object does not trigger change detection in Angular2?
I share array of objects to my components trough service. So in one moment I want to replace one of the array object's properties with the properties of new object(I replace the object). So my shared object should update in all templates where it is…

Свободен Роб
- 2,579
- 2
- 20
- 26
4
votes
1 answer
Change detection not triggered on some event
I have a component that subscribes to an Observable from a service. When the observable emits its next value some change happen in my component. The strange thing is that the component will or will not update the view depending on how the next value…

Ced
- 15,847
- 14
- 87
- 146
4
votes
2 answers
Angular2: Change detection inside observable
Just I tried my first app with Angular2 RC3 (Using Angular-CLI) and I'm lost with this...
I have a problem with "Change detection" of variable word. I update the word variable inside the subscribe method of Observable, but no changes…

Aral Roca
- 5,442
- 8
- 47
- 78
4
votes
3 answers
Angular 2 change detection - How are circular dependecies between components resolved?
I've read that Angular 2 change detection is uni-directional, heading from the top to the bottom of the component tree, and that it gets stable after a single pass, meaning that there are no multiple cycles of change detection. Given those…

Fjut
- 1,314
- 12
- 23
4
votes
1 answer
{{myArray}} now updates in the view as of beta.16
Change detection has changed.
Before beta.16, if your view contains {{myArray}}, that binding won't update if you don't modify the array reference. E.g., if you push() items onto the array, the view won't update to show the new item. The…

Mark Rajcok
- 362,217
- 114
- 495
- 492
3
votes
1 answer
Infinite loop when calling detectChanges() inside ngAfterViewChecked?
I recently reviewed some code where detectChanges() is called from ngAfterViewChecked. How does that not cause an infinite loop? Shouldn't it trigger another change detection cycle, which will call ngAfterViewChecked again? Or does the change…

Cory
- 51
- 2
3
votes
3 answers
Why to use Subject or BehaviorSubject in services when angular can detect latest values?
For example we have a service that has a list of items in it.
When we change this list in the service, all of the components that are using this list will detect this change. for example if you add a new item all of the components will detect it.
so…

Ali Rezaali
- 47
- 3
3
votes
1 answer
Angular performace - OnPush increases num of cycles
im trying to measure the performance differences in change detection strategies.
i've added the angular profiler, and checked with Default and then added onPush to most of our components and these are the results: (development mode)
Default: {…

Ori Damari
- 51
- 5
3
votes
0 answers
Lazy loaded module change detection - angular 5
I have a large application, that I have decided to split into multiple lazy loaded modules. While this worked for 'smaller' modules, for the bigger ones, I discovered that sometimes/most of the time, the views related to these modules, are not run…

RGLSV
- 2,018
- 1
- 22
- 37
3
votes
0 answers
How to swap components (with ChangeDetectionStrategy.OnPush)?
StackBlitz
This is what I have understood -
On clicking the swap button (present in sub-component-a.ts), an event is trigged.
This event is heard in app.component.ts which performs simple swapping operation on first two car objects.
The…

Nirmit Dalal
- 315
- 5
- 12
3
votes
3 answers
Angular OnPush Change Detection Propagation to a Child Components in a ngFor Loop
I am having an issue with onPush Change Detection in an Angular app.
I have created a demo app that illustrates the problem:
https://stackblitz.com/edit/angular-vcebqu
The application contains a parent component and a child component.
Both parent…

jptrue
- 152
- 1
- 5
- 15
3
votes
1 answer
Angular async pipe not triggering change detection from NgOnChange
I came across such code. The problem was that progress bar was not disappearing after selecting item that already was in cache (when api call inside cache was made it works fine). What I was able to came up with was that change detection was not…

pstr
- 31
- 1
- 4
3
votes
3 answers
Angular-2-material mat-ink-bar not on default tab
I am trying to lay out tabs on my website and I am using md-tab-group to achieve this. I am unable to get the ink-bar to be on the default but however, the content written on the respective tab is available. The ink-bar appears on click and not on…

chaitanya guruprasad
- 641
- 7
- 18
3
votes
1 answer
Angular change detection with pipe
I have an issue with change detection and pipe. I could not find a good way to work around it.
I have created a small project to reproduce it here. Go to the /monitor route.
When you click on the on Change button, it changes the value of the first…

PeeWee2201
- 1,464
- 2
- 15
- 23