AnteaterKit / angular2-yandex-maps

Angular 2 components Yandex Maps.
27 stars 23 forks source link

Is it possible to include library as NgModule? #16

Open AsenOsen opened 6 years ago

AsenOsen commented 6 years ago

I am not using SystemJS, but I need to import library via NgModule annotation. This is what I got: "Please add a @NgModule annotation.":

import { YaCoreModuleForRoot }  from 'angular2-yandex-maps';

...

@NgModule({
  declarations: [

    AppComponent,

  ],
  imports: [

    YaCoreModuleForRoot,

    ...
  ],

  bootstrap: [AppComponent]
})
export class AppModule {

}

Error(from web console):

Uncaught Error: Unexpected value 'YaCoreModuleForRoot' imported by the module 'AppModule'. Please add a @NgModule annotation.
    at syntaxError (compiler.es5.js:1690)
    at compiler.es5.js:15382
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15365)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26795)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26768)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26697)
    at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4536)
    at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4522)
    at Object.../../../../../src/main.ts (main.ts:11)
vanelizarov commented 6 years ago

You can try this way:

import { YaCoreModule } from 'angular2-yandex-maps'

@NgModule({
  ...
  imports: [
    YaCoreModule.forRoot()
  ]
})