javascript - Underscore JS, Grouping by an array Attribute. -
i'm trying use javascript group array 1 of it's attributes.
essentially have list of e-mail templates, , i'm trying group them category in can make collapsible accordion later.
i think might have syntax of underscore js wrong, or i'm addressing array incorrectly. calling groupby using following command:
console.log(_.groupby(result, 'im_category')); but array looks 'im_category' property hidden under attributes function. i'm not sure how there.
i've attached console.log of array looks , happens when run command. (i 3 different objects when should 2 if it's working correctly. )

your im_category property of attributes object in businessentity - _.groupby looking properties of businessentity. need create function iteratee:
var grouped = _.groupby(result, function (item) { return item.attributes.im_category; });
Comments
Post a Comment