Change default change detection strategy

五迷三道 提交于 2019-11-28 07:07:34

问题


How to set the default change detection strategy to OnPush? Can it be set globally somehow?

I want to avoid having to adding this line to every component

@Component({
    ...
    changeDetection: ChangeDetectionStrategy.OnPush,
    ...
})

回答1:


The change detection strategy can only be defined per component or directive not globally.

Using a custom decorator is discouraged because it will not be supported by the upcoming offline template compiler.



来源:https://stackoverflow.com/questions/37821998/change-default-change-detection-strategy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!