X Tutup
The Wayback Machine - https://web.archive.org/web/20200628000902/https://github.com/angular/angular/issues/37687
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If Data-binding an empty Array in template, the state will be retained #37687

Open
johnDLK opened this issue Jun 23, 2020 · 1 comment
Open

If Data-binding an empty Array in template, the state will be retained #37687

johnDLK opened this issue Jun 23, 2020 · 1 comment

Comments

@johnDLK
Copy link

@johnDLK johnDLK commented Jun 23, 2020

🐞 bug report

Affected Package

The issue is caused by package @angular/....

Is this a regression?

Description

I binding an empty Array in template as below. And click the ADD button to make some changes. When I click the Rebuild button, app-level-1 component will rebuild(its ngOnInit function will be called). And I expect it always input an empty Array into the sub-component. Actually the binding data will be retained. As a comparison, the the binding data in other two component will be reset.

20200623192341

Even if I deepen the level componet, rebuild all of them, the binding data still here, so maybe it stored in the entire angular lifecycle.

I found out how bugs happen:

  1. a component binding an empty Array in template.
  2. push some data into Array.
  3. delete the component. (even if delete its grandparent-componet)
  4. build a component that is in the same place of Angular tree.

the new component binding a Array as the old component instead of empty Array.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-zkdxh1

🔥 Exception or Error



Nope

🌍 Your Environment

Angular Version:



9.1.11

Anything else relevant?

It happend in Angular 7

@JoostK
Copy link
Member

@JoostK JoostK commented Jun 23, 2020

This appears to no longer be an issue with Ivy enabled, I suspect since #33705.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup