【发布时间】:2017-11-07 13:40:57
【问题描述】:
在 StackOverflow 上遇到与许多人相同的问题后,我无法理解什么是“外部角度区域”服务?
我已经检查了有关该主题的所有现有问题,这正是我需要问这个问题的原因:
- https://github.com/angular/angular/issues/5150
- Angular2: view is not updated from inside a subscription
- https://blog.thoughtram.io/angular/2016/02/22/angular-2-change-detection-explained.html
- http://blog.assaf.co/angular-2-change-detection-zones-and-an-example/
具有默认 ChangeDetectionStrategy 的任何组件中的代码示例: (考虑到视图中引用的 this.value)
this.myService.method().subscribe(e => {
this.value = e;
});
给定的服务不是“外部角度区域”,视图是刷新,另一方面,如果它是“外部角度区域”,视图不刷新,除非我们调用 ChangeDetectorRef.detectChanges()。
所以问题是:知道服务是在“角区”内部还是外部的条件是什么?
【问题讨论】:
标签: angular components observable zone