I am trying to query a JSON object using underscore library but I am unable to query the below JSON structure. '$scope.conScopeFreqStartDates' variable has the below JSON value.
I am passing 'frequencyCodeInput' value has 'Y' in the underscore script.
[
{
"consolidationScopeId": 4008,
"consolidationScopeCode": "S",
"consolidationScopeLabel": "Individual",
"frequencies": [
{
"frequencyCode": "M",
"frequencyLabel": "Monthly",
"startDates": [
"2016-01-31",
"2016-02-28"
]
},
{
"frequencyCode": "Y",
"frequencyLabel": "Annual",
"startDates": [
"2016-12-31",
"2017-12-31"
]
}
]
}]
I am trying to get the startDates from the JSON object,
controller
var startDates = _.findWhere($scope.conScopeFreqStartDates, {
'frequencies.frequencyCode': frequencyCodeInput
}).startDates;
$scope.startDates = startDates;
'startDates' is undefined for my above code.