0

I have 2 js files which should handle the configuration of my app. In the first i have the general config and in the second a more specific config. The second file is supposed to extend the first but when i try to access the object from it it says it's undefined. Here be code:

1ST file:

var Config = {

    application.name = ""

};

2ND file:

Config.menus.mainMenu = [

    {
        "route": "/address-validation",
        "prefix": "address",
        "label": "Address Validation",
        "icon": "icon-8"
    }, 
    {
        "route": "/reports/onhand",
        "prefix": "reports",
        "label": "Reports",
        "icon": "icon-9"
    }, 
    {
        "route": "/performance/sales",
        "prefix": "performance",
        "label": "Performance",
        "icon": "icon-10"
    }, 
    {
        "route": "/taxes/nonhumanminnesota",
        "prefix": "taxes",
        "label": "Taxes",
        "icon": "icon-11"
    }, 
    {
        "route": "/utils/product-location-mass-assignation",
        "prefix": "util",
        "label": "Utils",
        "icon": "icon-12"
    }, 
    {
        "route": "/administration",
        "prefix": "administration",
        "label": "Administration",
        "icon": "icon-7"
    }
];

1 Answer 1

1

Config.menus is undefined, so you can't set Config.menus.mainMenu on it.

Try this in your second file:

Config.menus = Config.menus || {}; // Set `Config.menus` to an empty object if it's undefined
Config.menus.mainMenu = [          // The rest of your code here
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.