Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以访问 angular(2+) ZoneJS 实例 (NgZone) 而无需像这样在构造函数中注入它:
... const zone = window['<angular zonejs path in window object>'] ...
现在,当我开发我的角度库时,我需要这样做:
class Test { constructor( zone: NgZone ) { initmyplugin(zone); } }
但我不想让用户关心 NgZone 的初始化。
NgZone您可以使用以下代码获取实例:
NgZone
ng.probe(getAllAngularRootElements()[0]).injector.get(ng.coreTokens.NgZone)
也可以看看