Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error No provider for NgZone

I have an application that uses Angular Google Maps to show a location. At the beginning I was able to show the map, but since a while (probably I have modified something) I am getting the following error:

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>

My code is: app.module.ts:

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

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

mycomponent.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>

I would really appreciate your help!

like image 557
Ivett Avatar asked Dec 17 '17 20:12

Ivett


1 Answers

You can provide NgZone manually:

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

@NgModule({
    providers: [
        // ...
        { provide: NgZone, useFactory: () => new NgZone({}) }
    ]
})
like image 91
Anton Poznyakovskiy Avatar answered Sep 20 '22 22:09

Anton Poznyakovskiy