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
3
votes
2 answers
ngOnChanges is not triggered when value changes from select
I have next html:
3
votes
0 answers
How can I trigger ngOnChanges only after every input values has been set in ngOnInit
How can I trigger ngOnChanges only after every input values has been set in ngOnInit.
My code -->
`ngOnInit() {
this.multiSelectorData.forEach(item=>{
this.allItems.push(item.data);
});
}
ngOnChanges(changes: SimpleChanges) {
…

RemyaJ
- 5,358
- 4
- 22
- 41
3
votes
1 answer
Angular 2 ngOnChanges not firing on rapidly changing input
I am using an Angular 2 @Input property to pass desired numeric values to the child component like this.
Parent component:
@Component({
selector: 'test-parent',
template: '

r.a.m-
- 499
- 5
- 12
2
votes
1 answer
Change detection not triggered when sending the same number as input to component
Here's my scenario:
I have a component, configured with the OnPush strategy, that displays a PDF document, page by page, and allows the user to scroll through pages and navigate to a certain page. It also exposes an input property scrollToPage which…

Sergiu
- 1,397
- 1
- 18
- 33
2
votes
1 answer
Angular EventEmitter doesn't seem to work
I have a main component which calls a child component which is a toggle pannel, when I active the toggle it emits the value of the toggle (true or false)
toggle-pannel.component.ts
@Output() toggleChange = new EventEmitter();
…

user3659739
- 434
- 6
- 19
2
votes
1 answer
watch for changes for the formControlNames and how to know which row of the changes in the formGroup for loop - Reactive Form
would like to watch for changes for the formControlNames in the formGroup for loop, but how do I know which index of the for loop that the changes has made. For example, if I want to watch the changes for formcontrolname for 'ruleType', the…

user21
- 1,261
- 5
- 20
- 41
2
votes
0 answers
ngOnChanges not firing
I can't figure out why ngOnChanges is executed if I run changeEnt() method and is not executed if I click on GoogleMaps marker.
This is my parent component
@Component({
selector: 'app-wl-map',
templateUrl: './wl-map.component.html',
styleUrls:…

firegloves
- 5,581
- 2
- 29
- 50
2
votes
2 answers
OnChanges does not trigger on partial object change
I am having issues while triggerin Angular(6)'s onChanges life cycle hooks. While emitting parameters from a compontent to a directive I want to hook on the changes.
The trigger works perfectly on one-dimensional variables, while objects are not…

Michael W. Czechowski
- 3,366
- 2
- 23
- 50
2
votes
0 answers
Angular 2 Change URL & content based on onChange value
So, I have a component that implements OnInitto refresh data based on API calls. The component is RoomComponent. In that component, I pass events that is an array of object. Then in room.component.html I render the dropdown consist of event.url. I…

SNahar
- 134
- 1
- 13
2
votes
2 answers
Angular - ngOnChange on FormGroup
I need to detect real time changes to the fields of a FormGroup. I have a simple parent-child components structure as follows:
parent component view
child component controller
@Input()
myForm:…

esseara
- 834
- 5
- 27
- 47
2
votes
1 answer
Angular 2+ ngOnChanges conflicts with eventEmitter
I have 2 components in the same parents. When I click a button onSubmit() in component 1, it will emit an event submittedPayment to parents who store the event into processingPayment then component 2 will receive this event via parents. However,…

Hoàng Nguyễn
- 1,121
- 3
- 33
- 57
2
votes
0 answers
Angular 2 ngOnChanges not firing when setting value via component reference
I'm creating a component dynamically this way:
let componentFactory = this._componentFactoryResolver.resolveComponentFactory(this.component);
this.componentRef =…

Stefan Holzapfel
- 364
- 3
- 13
1
vote
2 answers
Fetching firebase data on page load, data showing in console but not in html
I'm fetching an array of data from a firebase document, it's console logging but not showing on the front end. I am using async, awaits and the value to indicate that the data is loaded (doneLoading) is also returning true; however it is not…

TSH
- 39
- 1
- 5
1
vote
0 answers
ngOnChanges() not working after data update
I have a problem with updating value using NgOnChanges.
I am sharing data between components using @Input() decorator.
Component 1 html:

Simon
- 55
- 1
- 6
1
vote
1 answer
Use NgOnChanges to see when an @Input is changing and bind it on a template give undefined. Use set instead
As per title my initial situation is that I am calling with 2 way data binding a funciton in my template
template.html
{{arePresent()}}
This basically check if I have a @INput variable length of type string []
component.ts
@Input inputVar: string[]…

spring00
- 177
- 1
- 4
- 13