ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.51k stars 574 forks source link

ERROR in Cannot read property 'map' of undefined, resolving symbol AppModule #391

Closed anand-ma closed 6 years ago

anand-ma commented 7 years ago

I'm submitting a ... (check one with "x")

[X ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior webpack: bundle is now INVALID. webpack: wait until bundle finished: /index.html Hash: 63e75ff62ec19674e859 Time: 7591ms chunk {0} styles.bundle.css, styles.bundle.map, styles.bundle.map (styles) 76.7 kB {3} [initial] chunk {1} main.bundle.js, main.bundle.map (main) 11.8 kB {2} [initial] chunk {2} vendor.bundle.js, vendor.bundle.map (vendor) 4.08 MB [initial] chunk {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry]

ERROR in Cannot read property 'map' of undefined, resolving symbol AppModule in C:/Users/507644/Workspace/ATT/shared/firstnet-shared/src/app/app.modul e.ts, resolving symbol AppModule in C:/Users/507644/Workspace/ATT/shared/firstnet-shared/src/app/app.module.ts webpack: bundle is now VALID.

Expected/desired behavior

Reproduction of the problem If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:btpW3l0jr5beJVjohy1Q). run ng serve

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment: app.module.ts

export function createTranslateLoader(http: Http) {
  return new TranslateStaticLoader(http, '/assets/i18n', '.json');
}

  imports: [
    BrowserModule,
    ReactiveFormsModule,
    HttpModule,
    TranslateModule.forRoot({
      provide: TranslateLoader,
      useFactory: (createTranslateLoader),
      deps: [Http]
    }),
    routing
  ],

angular cli

{
  "name": "****",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "core-js": "^2.4.1",
    "intl": "^1.2.5",
    "ng2-translate": "^5.0.0",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "^1.0.0-beta.24",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "phantomjs-prebuilt": "^2.1.14",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }
}
SamVerschueren commented 7 years ago

Are you sure this is due to ng2-translate? Try removing TranslateModule.forRoot from the AppModule and try again.

anand-ma commented 7 years ago

@SamVerschueren you are right, i'm getting the same error after removing. But do you have any suggestions on this anyway?

lebnic commented 7 years ago

I had a similar issue. Fixed it by changing:

@Inject(forwardRef(() => FrameComponent)) private translate: TranslateService, private cookieService: CookieService, private dataService: DataService, public app:FrameComponent) {}

To

@Inject(forwardRef(() => FrameComponent)) public app:FrameComponent, private cookieService: CookieService, private translate: TranslateService, private dataService: DataService) {}

Notice "translate" was just after "@Inject" ...