LoDash Playground
by brendanbond
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.0/lodash.min.js"></script>
JavaScript
let applicationTypeDataSource = [{
"area": "a",
"types": [
"q",
"w",
"e"
]
},
{
"area": "b",
"types": [
"q",
"w",
"e"
]
},
{
"area": "c",
"types": [
"q",
"w",
"e"
]
}
];
let area = 'a';
let type = 'q';
let form = {
config: {
applicationTypeDataSource
}
}
let selected = _.find(
_.find(
_.get(form, "config.applicationTypeDataSource", []),
(item) => item.area === area
).types,
(item) => item.type === type
);
let first = _.find(
_.get(form, "config.applicationTypeDataSource", []),
(item) => item.area === area
);
console.log(_.find(first.types, (item) => item.type === type);