Find a value in json object using lodash methods flatten and find -
using lodash want find team id 3229. tried following not returning anything.
var team = _.chain(data.teams) .flatten("divisionteams") .find({"id":3229}) .value();
here plunker code.
http://plnkr.co/edit/udwzrkx3zkyjyf8uwo7i
for json data please see file data.js in plunker.
please note cannot change json data since calling test api.
flatten
doesn't take argument, see docs. need either map
or pluck
divisionteams
.
_.chain(data.teams) .pluck('divisionteams') .flatten() .find({id: 3232}) .value();
Comments
Post a Comment