mardi 5 novembre 2019

Getting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember'

I am trying to write a javascript helper function in my Ember application called compare.js, and that js file is trying to import Ember, where its throwing error, can anybody please suggest me something how to get-rid of this type errors? Here is my compare.js files code - thank you.

import Ember from 'ember';

export function compare(params) {
    if (params[3]) {  //handle case insensitive conditions if 4 param is passed.
        params[0] = params[0].toLowerCase();
        params[2] = params[2].toLowerCase();
    }
    let v1 = params[0];
    let operator = params[1];
    let v2 = params[2];
    switch (operator) {
        case '==':
            return (v1 == v2);
        case '!=':
            return (v1 != v2);
        case '===':
            return (v1 === v2);
        case '<':
            return (v1 < v2);
        case '<=':
            return (v1 <= v2);
        case '>':
            return (v1 > v2);
        case '>=':
            return (v1 >= v2);
        case '&&':
            return !!(v1 && v2);
        case '||':
            return !!(v1 || v2);
        default:
            return false;
    }
}

export default Ember.Helper.helper(compare);

I want to be able to import or use this function in my hbs file, how can I do it any help please to fix these two things please - need some help - thank you.




Aucun commentaire:

Enregistrer un commentaire