Respond when Angular (re)sets data-bound input properties. The method receives a SimpleChanges object of current and previous property values. Called before ngOnInit and whenever one or more data-bound input properties change.
Questions tagged [ngonchanges]
123 questions
0
votes
1 answer
ngOnchanges and DoCheck in angular
When study the difference between ngOnChanges and DoCheck in Angular, I see something I cant explain and need your help.
Basically, I understand that ngOnChanges can't recognize the change of array or object and DoCheck can. I created the stackblitz…

Tony
- 1,106
- 1
- 10
- 17
0
votes
1 answer
Angular 9 (or 2+) does not detect CHANGES, if injected via | async, on the parent's HTML [Input()], if they are too fast - hundreds of milliseconds
I have an Observable giving me some log changes (sometimes hundreds per milisecond).
I subscribe to this Observable, on ngOnInit() and can console ALL the changes beautifully.
Problem comes when i pipe async this Observable into an HTML @Input()…

Pedro Ferreira
- 493
- 7
- 14
0
votes
1 answer
ngOnChanges is not called but the view is updated correctly
I have a question related to the following code:
Child
export class ChildComponent implements OnChanges {
public @Input() data: string[];
ngOnChanges(changes: SimpleChanges) {
console.log('I am here');
}
}
Child Template
{{…

Mr. Mars
- 762
- 1
- 9
- 39
0
votes
0 answers
Angular8: Run oninit or onchanges for components referenced in response text
I have MathJacks loaded and working when the text is put into a template. But I am retrieving a large body of text from the server. This text is in HTML as it is heavily parsed and setup on the server.
(FYI I'm using the sanitizer on the returned…

LeosSire
- 93
- 3
- 13
0
votes
1 answer
Angular ngOnChanges not called after ngOnDestroy of parent
I have a child component which accepts an input
In the child component, I detect changes to the customModel input by doing:
@Input() customModel: CustomModel;
ngOnChanges(changes:…

user5155835
- 4,392
- 4
- 53
- 97
0
votes
1 answer
Angular listen for value change of a number property (NOT @Input) with - ngDoCheck?
I have a FormGroup array of rates namely ratesMainArray being @Input from a parent to my child component. I am filtering it in ngOnChanges by its special or normal key value every time its length in the parent component changes and storing the…

mike87
- 309
- 2
- 11
0
votes
2 answers
ngOnChanges not getting called twice although we are changing the value of property twice in parent component
There are two components namely ParentComponent and ChildComponent. We are binding a variable from parent component to child component. As per angular documentation "ngOnChanges" of child component gets called whenever the value of property in…

kushagra
- 57
- 2
- 11
0
votes
1 answer
Angular - how do I get data to load with ngOnChanges
I have a demo here
It's a angular app where I'm trying to create a D3 chart.
The chart data is created with a createDate function, creating random data and dates.
I want the chart to update with the update button so I'm using ngOnChanges but this…

ttmt
- 5,822
- 27
- 106
- 158
0
votes
1 answer
Angular doesn't detect swiper slide changes
I'm using swiper library. In API from above link you can find that mySwiper.activeIndex is returning currectly selected slide. What I want to do is update my service whenever slide is changed so my app will know which slide is selected in other…

BT101
- 3,666
- 10
- 41
- 90
0
votes
1 answer
ngOnChanges not getting Fired
I am testing the ngOnChanges method in my running code. But it seems the ngOnchanges isnt getting called though it compiles . Below is my code.
create-employee.component.html:

jayendra bhatt
- 1,337
- 2
- 19
- 41
0
votes
1 answer
Angularfire2, Firestore Document Retrieval Issue (using .get, possibly related to ngOnChanges)
My application structure has 1 service and 2 components:
Service: Holds all of the firestore connections
ViewComponent: Gets a list from the service and displays it
ItemManagementComponent: Displays a form and allows the user to add a new entry.
The…

Rusty Shackleford
- 57
- 1
- 9
0
votes
2 answers
Angular replace component
There is a case where the data are being sent from two different components; let's say OneComponent and TwoComponent and there is a ResultComponent which receive these data via Input() decorator. Also, in ResultComponent the data are merged using…

corry
- 1,457
- 7
- 32
- 63
0
votes
2 answers
ngIf is not triggered when value changes
I have a simple mat-spinner which should be triggered when isLoading is true. The variable changes as intended, but the mat-spinner is not visible. It is only visible if I change isLoading to always be true.
Am I missing something?
Thanks in…

lennertr
- 150
- 1
- 10
0
votes
2 answers
Angular ngOnChanges does not get called
Angular does not invoke change detection when an Input property is changed. I have read that angular does not call onChanges unless there is a change in bindings, but in this example I have binded the input to ng datePicker model, but still…

Kaushik
- 114
- 2
0
votes
0 answers
Angular ngOnChange event not fired on Firefox
This problem only happens on Firefox, works fine on Chrome and Safari.
I have no clue why this is happening and I've been googling and stack overflowing, but none of them facing the same problem as I do.
The whole web app doesn't interact at all on…

MaXon
- 465
- 2
- 8
- 17