ReferenceError: L is not defined Angular 2 RC.5
aderbas opened this issue · 4 comments
I'm trying to use with Angle 2 RC5. I'm using angular-cli and what I did was:
$ npm install --save leaflet
$ npm install --save-dev @types/leaflet
ReferenceError: L is not defined
at new MapService (http://localhost:4200/main.bundle.js:66441:32)
at DebugAppView._View_MainViewComponent_Host0.createInternal (MainViewComponent.ngfactory.js:20:26)
at DebugAppView.AppView.create (http://localhost:4200/main.bundle.js:60438:21)
at DebugAppView.create (http://localhost:4200/main.bundle.js:60651:44)
at ComponentFactory.create (http://localhost:4200/main.bundle.js:43429:36)
at ViewContainerRef_.createComponent (http://localhost:4200/main.bundle.js:43998:45)
at RouterOutlet.activate (http://localhost:4200/main.bundle.js:51268:40)
at ActivateRoutes.placeComponentIntoOutlet (http://localhost:4200/main.bundle.js:15482:16)
at ActivateRoutes.activateRoutes (http://localhost:4200/main.bundle.js:15459:22)
at http://localhost:4200/main.bundle.js:15421:19
Sorry, I know this is not an issue of his example but you have any tips for this error?
Thks.
If you don't use typings to install type definitions, make sure add the reference in public_src/lib.ts
:
/// <reference path="path/to/leaflet/index.d.ts" />
Also, ng2-bootstrap haven't supported RC5. If you would like to use the latest Angular 2, use ng-bootstrap instead.
I am closing this issue as we have moved from RC.
I had a similar error, even though my type definitions seemed correct. It turned out I also had Mapbox.js typings installed (@types/mapbox) which were in conflict with the Leaflet typings. The solution was to remove the Mapbox.js typings.
It would be good to open an issue at DefinitelyTyped.