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. )

console.log of me running commands.

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; }); 

http://jsfiddle.net/jwnzh8w0/


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -