Angular 如何为 ChangeDetectionStrategy.OnPush 更新 UI

问题描述 投票:0回答:1

我有 Angular 写的项目 但是在我的组件中使用 ChangeDetectionStrategy.OnPush 我将 properti 更新为存储中的新值,但 UI 未更新 所以任何时候都可以帮我解决这个问题(可以使用 Obserbable for pipeAsync) 谢谢

enter image description here

angular ngrx
1个回答
0
投票

使用 OnPush,你需要告诉 Angular Component 在事件之外检测变化和更新。 对于你的情况,我认为

this.cdRef.markForCheck(); // Tell Angular to run detectChanges on this component
可能有用。

© www.soinside.com 2019 - 2024. All rights reserved.