gpt4 book ai didi

angular - 错误 NgZone 没有提供者

转载 作者:太空狗 更新时间:2023-10-29 17:15:13 25 4
gpt4 key购买 nike

我有一个使用 Angular Google map 显示位置的应用程序。一开始我能够显示 map ,但一段时间后(可能我已经修改了一些东西)我收到以下错误:

ERROR Error: Uncaught (in promise): Error: StaticInjectorError[NgZone]: 
StaticInjectorError[NgZone]:
NullInjectorError: No provider for NgZone!
at _NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveNgModuleDep (core.js:10585)
at NgModuleRef_.get (core.js:11806)
at resolveDep (core.js:12302)
at _NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveNgModuleDep (core.js:10585)
at NgModuleRef_.get (core.js:11806)
at resolveDep (core.js:12302)
at resolvePromise (zone.js:824)
at resolvePromise (zone.js:795)
at eval (zone.js:873)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js:4620)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at drainMicroTaskQueue (zone.js:602)
at <anonymous>

我的代码是:应用程序模块.ts:

import { AgmCoreModule } from '@agm/core';

imports AgmCoreModule.forRoot({apiKey:'...'})

我的组件.html

<agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom">
<agm-marker [latitude]="lat" [longitude]="lng">
<agm-info-window>
<div>
my text
</div>
</agm-info-window>
</agm-marker>

非常感谢您的帮助!

最佳答案

您可以手动提供 NgZone:

import { NgZone } from '@angular/core';

@NgModule({
providers: [
// ...
{ provide: NgZone, useFactory: () => new NgZone({}) }
]
})

关于angular - 错误 NgZone 没有提供者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47859373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com