Wednesday, 15 March 2017

Edit Global array in Express

I want to change one item from array from app locals variable and i am not sure how to do this

Here is what i have set as global

app.locals.products=[{name: 'a',url: '/a' },
    {name: 'b',url: '/b' },
    {name: 'c',url: '/c' },...

I want to edit them and set active product from routes and do something like this

    products:[{name: 'a',url: '/a' active:true}],

But when i do this it will remove all the other items and set only the product the one i wrote. Is there a way to edit just the one i need and leave all the rest unchanged?



via Bill

No comments:

Post a Comment