I wanted to wrap a function named loanCalc in a module to be consumed by other Ember objects in an Ember-cli project. I did the following:
$ ember g util loanCalc
Ember-cli creates a file named app/loan-calc.js. loan-calc.js looks like this:
export default function loanCalc() {
// other regular javascript code
return ...}
I tried to use loanCalc in a component by importing the module using:
import {loanCalc} from '../../../../utils/loan-calc.js';
When I run the application, I get this error:
Uncaught Error: Could not find module 'tw/utils/loan-calc.js' imported from 'tw/pods/components/scenarios/display-scenario/component'
The component.js file is located in tw/app/pods/components/scenario/display-scenaro. The loan-calc.js file is located in tw/app/utils.
The file is clearly there. What am I doing wrong? Do I need to do something in the ember-cli-build.js file or some other ember-cli-generated files to make this work? I'm new to ember-cli and still trying to find my way around.
Aucun commentaire:
Enregistrer un commentaire