lundi 10 juillet 2017

EmberJs: Not able to resolve config/environment.js from a service

Ember version - ~2.8.0

This might seem really simple, but it has got on to nerves after hours of looking through for a fault.

I am trying to simply import the config/environment.js file into a service(at app/services/myservice.js) and make use of the contents. like this -

import config from "../config/environment";

But, all i get is "Cannot read property 'APP' of undefined" in the console, if i do config.APP. Even though environment.js is present physically, under demo-app/config/environment.js.

i am confused, if i am missing some convention, or some setting somewhere that needs to be present, in order for this to resolve correctly.

Please help.

Also(Although this was obvious), if i change the import as import config from "../../config/environment";, it says Could not find module 'config/environment' imported from 'demo-app/services/myservice'

I do understand the app folder is skipped in the resolution. i.e. the physical address of demo-app/app/something... becomes demo-app/something... . But some one please explain why it may not be resolving. It is in the fresh installation of the App.




Aucun commentaire:

Enregistrer un commentaire