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

Change detection not firing with object #54

Closed
sdornan opened this issue Feb 15, 2018 · 2 comments
Closed

Change detection not firing with object #54

sdornan opened this issue Feb 15, 2018 · 2 comments
Labels
Milestone

Comments

@sdornan
Copy link

sdornan commented Feb 15, 2018

I am using the pipe very similarly to the example given with ngx-filter-pipe v2.0.0 and angular v5.2.5.

Template:

<input type="text" placeholder="Find by name" [(ngModel)]="targetFiltersFilter.name">

<mat-chip-list>
  <mat-chip *ngFor="let target of targetFilters | filterBy: targetFiltersFilter">{{ target.name }}</mat-chip>
</mat-chip-list>

Inside component:

targetFilters: any[] = [{ name: 'aaaa' , selected: false },  { name: 'bbbb', selected: false }, ... ];
targetFiltersFilter: any = { name: '' };

It seems that the pipe isn't being triggered when I type into the input. I can see that the pipe gets triggered once when the page first loads but not at all after that when I modify targetFilterFilter's name attribute via the text field. The pipe does get fired, however, if I change its input to a string value instead of an object, or if I change pure: false in the pipe declaration. This says to me that Angular is doing some type of too shallow comparison for its change detection that doesn't take into account if an object's properties have been modified. Any advice? Would some change within a recent version of angular itself cause this?

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [x] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request
@sdornan
Copy link
Author

sdornan commented Feb 15, 2018

Just found this in the docs:

"Angular ignores changes within (composite) objects. It won't call a pure pipe if you change an input month, add to an input array, or update an input object property."

https://angular.io/guide/pipes#pure-pipes-and-pure-functions

@VadimDez VadimDez added the bug label Feb 18, 2018
@VadimDez VadimDez added this to the 2.1.0 milestone Feb 18, 2018
@VadimDez
Copy link
Owner

Fixed in 2.1.0

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

No branches or pull requests

2 participants