Array push not firing to child @Input
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
I’ve this child componentA inside a parent component
<componentA [setTask]="tasks"></componentA>
in the componentA setTask is an Input
@Input() set setTask(value: Array<any>) { // Do stuff }
now whenever I push new item in the parent component either using this.tasks.push(item) or Array.prototype.push.apply(this.tasks, items)
the Input in the child component is not being triggered
Expected behavior
On every update on the Array the Input should be triggered. This is working just fine in 4.4.6, but not after I’ve updated to Angular 5
Environment
Angular version: 5.1.2
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Array when push in child components not update follow data ...
if you do this.data.push(val) this will not trigger the input property to recognise a new array as it is still the same reference...
Read more >How to detect @input value changes in Angular Child ...
The reason is Objects and Arrays are passed by reference. And when object properties are changed inside the component, reference won't change.
Read more >3 Ways to Pass Async Data to Angular 2+ Child Components
Solution 2: Use ngOnChanges ... ngOnChanges is a lifecycle hook that run whenever it detects changes to input properties. That means it's ...
Read more >Array.push() won't update Lightning Web Component View
When items are added to an array, it will never change the pointer, thus @track sees no change. However, in my workaround above, ......
Read more >Detecting @Input changes in Angular with ngOnChanges ...
In this post you'll learn how to detect changes to an @Input property in Angular. ... Join 81,092 developers pushing their limits.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t know why but no Angular Plunkers works for me… Pain in the ass…
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.