ngClass/ngStyle are evaluated before exported directives
See original GitHub issue🐞 bug report
Affected Package
@angular/core 8.x
Is this a regression?
The behaviour seemed different in Angular 6 (7 was never testet). Hard to say because a refactoring to onPush strategy was made simultaniously. Sorry for that.
Description
I used to have a little helper directive which caches values inline in the template by using the exportsAs technique. This directive only holds a value property, is selected via “store-value” attribute and exports as “store”. The usage is as follows:
<div #metaInfoStore=store [store-value]="getItemMeta(item)">{{metaInfoStore.value.name}} {{metaInfoStore.value.description}}</div>
Simple and works like a charm without having to implement anything in ngDoCheck(). The issue starts when i use the store value within class bindings (ngClass).
<div #metaInfoStore=store [store-value]="getMeta()" [ngClass]="{'locked': metaInfoStore.value.locked}">{{metaInfoStore.value.name}} {{metaInfoStore.value.description}}</div>
When using the onPush change detection strategy, the ngClass directive is evaluated BEFORE the store directive is. I did not change any of my code, but updated to angular 8 and set change detection strategy to OnPush.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-1xr6cb The div Element should receive the ‘locked’ class which it doesn’t.
Thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
@mhevery From what I can tell, it looks like @Andy1605 is trying to file a bug report about Angular 8, which is View Engine by default. I don’t think this is an Ivy issue.
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.