-
Notifications
You must be signed in to change notification settings - Fork 772
Class directive not applied correctly for ngFor and ChangeDetectionStrategy.OnPush #206
Comments
This will be fixed with PR https://github.com/angular/flex-layout/pull/223/files. Also here is a working Plunkr version (with the latest flex-layout code).
.item.showOnGtXs {
color: #932e2e;
background-color: #DDECFE
} Here are some docs explaining how to add/remove/merge classes: https://github.com/angular/flex-layout/wiki/ngClass-API#responsive-features
|
* add missing static `ngClass` and `class` selectors * add tests to demonstrate fallbacks to static selector values Fixes #206.
Reopen since the ngFor issue is still present. |
@dfmartin - see working Plunkr https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview Note: you do not need to use
|
* ngClass now properly differentiates between `ngClass` and `class` * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206.
…rategy.OnPush strategies * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206.
…rategy.OnPush strategies * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206.
…rategy.OnPush strategies * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206, fixes #215.
…rategy.OnPush strategies * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206, fixes #215.
…rategy.OnPush strategies * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. * fix class lt-<xx> selectors > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206, fixes #215.
…rategy.OnPush strategies * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. * fix class lt-<xx> selectors > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206, fixes #215.
…rategy.OnPush strategies (#228) * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. * fix class lt-<xx> selectors > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes #206, fixes #215.
* add missing static `ngClass` and `class` selectors * add tests to demonstrate fallbacks to static selector values Fixes angular#206.
…rategy.OnPush strategies (angular#228) * fix(ngClass): properly differentiate between `ngClass` and `class` api usages * `class.<xxx>` are destructive overrides (as seen in `NgClass::klass`) * `ngClass.<xxx>` use iterables to merge/enable/disable 0...n classes * fix(ngClass,ngStyle): support ChangeDetectionStrategy.OnPush * Add support for both **OnPush** change detection strategies and for @input changes. * fix class lt-<xx> selectors > @see https://plnkr.co/edit/jCICQ1GXFnzFqFTFlXwh?p=preview fixes angular#206, fixes angular#215.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I am trying to use ChangeDetectionStrategy.OnPush along with an ngFor, but have found that the class/ngClass directive does not work when using OnPush. What I am finding is that the appropriate class is being applied to only the last item in the list.
This occurs only on the initial render. If the screen is resized to cause a change then everything works from that point forward. I have tried ChangeDetectorRef.markForCheck() and seen no change. One thing that causes some head scratching is that the class is applied to the last item so it's obvious the class directive is firing correctly somewhere.
I have put up a plunker (appropriated from a demo for side nav). If you look at the file
src/app/responsive-sidenav.ts
. There is a line in the meta that can be commented out to see the "correct" behavior.http://plnkr.co/edit/zalFNqqiznHUyg33FJII?p=preview
The text was updated successfully, but these errors were encountered: