Here is a simplified version of an object I get from a service.
[
{
"lookupID": "Annual Leave",
"lookupCode": "Annual Leave",
"reasonRecords": [
{
"reason": "Annual",
"docRequired": "N"
},
{
"reason": "Mandatory",
"docRequired": "N"
}
]
},
{
"lookupID": "Accumulated Leave",
"lookupCode": "Accumulated Leave",
"reasonRecords": [
{
"reason": "Accumulative",
"docRequired": "N"
},
{
"reason": "Cancellation",
"docRequired": "Y"
}
]
},
{
"lookupID": "Study Leave",
"lookupCode": "Study Leave",
"reasonRecords": [
{
"reason": "Examination Leave",
"docRequired": "N"
},
{
"reason": "Research Leave",
"docRequired": "N"
}
]
}
]
I need to populate two dopdowns (which can be repeated x number of times)
End result should look something like this

The first is already populated and working, it displays all the possible LookupID's
<select class="form-control" id="leavetype_{{$index}}" ng-model="leaveEntry.leaveTypeKey" value="leaveEntry.leaveTypeKey" ng-required>
<option ng-repeat="leaveType in leaveTypes" value="{{leaveType.lookupCode}}">{{leaveType.lookupCode}}</option>
</select>
The second dropdown should display the possible reasons based on the lookupCode selected in the previous dropdown
It's currently just hardcoded to show the reasons of the first lookupCode
<select class="form-control" id="reason_{{$index}}" ng-model="leaveEntry.reason" value="leaveEntry.reason" ng-required>
<option ng-repeat="reasonRecord in leaveTypes[0].reasonRecords" value="{{reasonRecord.reason}}" >{{reasonRecord.reason}}</option>
</select>
How do I dynamically populate the second dropdown ?
Bonus: a field then needs to display the appropriate docRequired value based on the selections