Questions tagged [angular2-changedetection]
473 questions
9
votes
2 answers
Angular 2 OnPush change detection for dynamic components
I have an Angular component that dynamically creates various other types of component inside itself. It binds its own properties to child component @Input properties via an OnChanges hook.
This binding works fine when the child component's change…

Chris Fulstow
- 41,170
- 10
- 86
- 110
9
votes
2 answers
Angular2 manually implement change detection using ApplicationRef
Getting a change detection error
Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'
so I want to manually run another round of change detection. Found information about using ApplicationRef.tick() but…

Drew13
- 1,301
- 5
- 28
- 50
8
votes
2 answers
Showing Validation messages with Reactive Forms and ChangeDetectionStrategy.OnPush
I'm trying to migrate an app to using ChangeDetectionStrategy.OnPush. However, I'm running into a bit of a blocker trying to work with some reactive forms.
I've got a reusable control that shows validation messages based on some of the state flags…

Daniel Schaffer
- 56,753
- 31
- 116
- 165
8
votes
1 answer
What is the performance impact for a class / interface with a lot of fields?
I have a class (interface) in my angular 4 app which has a lot of fields.
Note that the instance of this class/interface is immutable (i.e. the members will NEVER be changed).
E.g.
public interface IHaveALotOfFields {
field1: string;
//...
…

OschtärEi
- 2,255
- 3
- 20
- 41
8
votes
1 answer
Angular2 change detection misunderstanding - With plunker
I'm trying to fully understand change detection with Angular2 final.
This include:
Dealing with change detection strategies
Attaching and detaching change detector from a component.
I thought I already got a pretty clear overview of those…

Clement
- 3,860
- 4
- 24
- 36
7
votes
4 answers
Angular Change detection not working with ChangeDetectionStrategy.OnPush in HttpClinet.Subscribe
I have reproduced a simple stackblitz demonstrating the issue I have been having. The problem is that I have a parent component that passes a boolean to a child component. This boolean is an @Input on the child component. It is important to note…

Pat
- 255
- 2
- 4
- 16
7
votes
1 answer
Angular NgZone.runOutsideAngular and OnPush change detection strategy
I'm trying to optimize the performance of code in angular application.
I know that I can runOutsideAngular some code in order not to cause change detection on each code run or event.
However, do I need to use runOutsideAngular when I utilize OnPush…

Sergey
- 7,184
- 13
- 42
- 85
7
votes
2 answers
How to detect change from one component into other
Angular 4. Github source
I have a menu which is filled by a web service. The web service is in taskService, but is not necessary now.
ngOnInit() {
this.getTasks();
}
getTasks(): void {
this.taskService.getTasks()
…

ValRob
- 2,584
- 7
- 32
- 40
7
votes
1 answer
Angular - Input data not immediately available on child component, why?
I have a child Calendar Component that receives events from his father through an input field.
@Input() private events: any[];
When the month changes the parent gets new events from an API Service and calls the child component to show them.
private…

Willa
- 73
- 6
7
votes
1 answer
Angular 4 + Jasmine Unit Tests: Reasons why fixture.detectChanges() may not work upon change of @Input() variables
Been running into this one issue and scouring the internet about fixture.detectChanges() where it does not recognize changes in @Input() when explicitly inserting mock data. There are tons of threads and docs that describe the setup but not…

Eric
- 73
- 1
- 1
- 9
7
votes
1 answer
Angular 2 Change Detection Breaks Down with Electron
I have an Electron app using Angular 2. The app works fine until a load data from a local JSON file using ipcRenderer. Then buttons which act on data in a service no longer trigger change detection process to update the view. I created a simplified…

Marshmellow1328
- 1,205
- 3
- 18
- 27
7
votes
1 answer
angular 2 subscribe value change not reflecting on html
This is quite confusing to me. I might not have a solid understanding of how subscription works.
Angular 2 finalized version
Goal: Hide/Show navigation menu based on roles
Approach: I use Facebook to authenticate users. After authentication, user…

Chuck
- 209
- 1
- 4
- 11
7
votes
3 answers
Angular2: Watch an external variable outside of angular
I want to be able to watch and update when a variable outside of angular2 changes. So let's say I have this in an external javascript file:
var test = 1;
How can I bind this variable to a property in a component?
@Component({
...
})
export…

Sebastian Olsen
- 10,318
- 9
- 46
- 91
6
votes
1 answer
Change component input from ngOnChanges, while using OnPush strategy
I'm having a problem with an Angular 6 application:
The problem
Let's say I have 2 components: parent and child.
the child has 2 inputs.
While 1 input changes, inside the ngOnChanges() the child component emit somthing to the parent component.
Then…

Naor Talmor
- 244
- 2
- 10
6
votes
2 answers
Is it normal for Angular to re-render infinitely even when no changes are made?
The question
Is Angular designed to constantly re-check everything in order to detect changes? I'm coming from the React world and I was expect something like event triggered -> re-rendering. I don't know if this is something from my app or…

Raul Rene
- 10,014
- 9
- 53
- 75