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
0 answers
ngDoCheck not firing for an object with array of items
I am listening to changes on an object property with help of ngDoCheck The implementation is like below
differ: any;
pageSettings:SelectionSettings;
where SelectionSettings is
export interface SelectionSettings {
boolPpt: boolean;
maxRows:…

Sebastian
- 4,625
- 17
- 76
- 145
0
votes
1 answer
Angular: handle object changes in ngFor, force print
I have my app.component with a list of objects
class Hero {
alias: string;
constructor(public firstName: string,
public lastName: string) {
}
}
class AppComponent {
...
heroes: Hero[] = [
new Hero("foo",…

Sampgun
- 2,822
- 1
- 21
- 38
0
votes
1 answer
ngOnChange only triggers after clicked somewhere on the screen after subscribe
I have the following components.
Parent:
@Component({
selector: 'test'
})
onAccountChange(account: AccountItem): void {
this.appService.callApi.subscribe((data) => {
this.availableInstrument = data
})
}
And my Child component is as…

fa72
- 1
- 2
0
votes
1 answer
angular - blur event not resetting value
I have a search bar functionality where I use ngOnChanges to detect the search term change, enabling me to filter through some data. However, if I use the previous search term value again, this change will not be caught. Now I know this makes sense…

Manuel Brás
- 413
- 7
- 21
0
votes
2 answers
Angular NGRX / Reactive Form and ngOnChanges timing issue
Angular 9
I'm trying to use ngOnchanges to trigger the load to my form. The data for the form is coming from an @input from the shell-component.
The problem I have is ngOnChanges is firing BEFORE ngOnit and the form has not been built yet for the…

Darren Street
- 1,652
- 17
- 21
0
votes
3 answers
ngOnchange doesn't detect dynamic changes
I'm using angular for developing eCommerce app. I'm Using OnChange lifecycle hook to detect changes in the cart component and calculate total price. However, changes are not being detected.
Typescript Code:
import { ChangeDetectionStrategy,…

Ahmed Abdelghany
- 143
- 2
- 8
0
votes
2 answers
Angular NgOnChanges behaving weirdly
I have a parent component sending data to a child component via Input. NgOnChanges won't work as I expect it to be. I know that it does not work well with object/array because they are sent via reference so Angular has trouble detecting changes.
So…

Specialka
- 51
- 1
- 10
0
votes
1 answer
How to update subscribed value in html on change in Angular?
After clicking "Edit", "editStatus" function is called, then the value of "order.status" is changing. But the html view remains the same - displays the old status of order. It changes only after refreshing the page. How can I do the status show the…

Weronika
- 368
- 3
- 24
0
votes
1 answer
Angular 9 ngOnChange: SimplesChanges.firstChange is always false but the value changed
I have this component. I want to do something just the first time the @Input changes. The problem is that the changes.firstChange is always false (on init and after changed).
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
…

Diego Ramirez
- 91
- 5
0
votes
2 answers
How to trigger a change in value with ngOnchanges?
I have a parent component and a reusable child component. I want to triger the values in the child component and display the result as the input in parent component changes without using any submit button. Whenever there is any change in the input…

Jeet
- 359
- 1
- 6
- 24
0
votes
2 answers
Angular ngOnChanges in child doesn't trigger after subscribe manipulates data
I have a problem with ngOnChanges not being fired for a child component after data is being manipulated in parent via subscribe method.
Basically my main component looks like this:
public imageGroups: IImageGroup[];
public status$:…

Lubos
- 39
- 5
0
votes
1 answer
Passing a parameter to ngOnChanges?
I have an ngOnChanges that used SimpleChanges
ngOnChanges(changes: SimpleChanges): void {
for (const propName in changes) {
if (changes.hasOwnProperty(propName)) {
console.log(propName);
switch (propName) {
case…

lmngn23
- 511
- 3
- 15
0
votes
0 answers
Angular OnChange, DoCheck and Observables
Im wondering if someone could please advise.
I have data coming in through a Socket.io service to a component. Trying to decide what approach is most logical?
I can either:
A. Have the parent component call the observer and Push the data to the…

Crash1hd
- 615
- 7
- 23
0
votes
1 answer
ngOnChanges fires only for the first time
I'm taking @Input() from parent component, and using ngOnChanges to catch the change. But it only fires once. It changes the current value, but the previous value is always undefined. Here's what I'm…

nyxtron
- 41
- 8
0
votes
1 answer
Angular: API request based on Input changes
I am doing some tests using the SWAPI api (Star Wars); my goal is to call the api as the user clicks on a character list, so a film list where this character has participated can be displayed as well. Im trying to achieve this through the…

Mellville
- 1,027
- 2
- 18
- 39