question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Array push not firing to child @Input

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dlarrcommented, Oct 4, 2018

I don’t know why but no Angular Plunkers works for me… Pain in the ass…

0reactions
angular-automatic-lock-bot[bot]commented, Sep 14, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found