I am pretty new with angular , so i need all the help possible. My problem is as follows. I have a html form where in there are 2 selects, the data for the selects is fetched from an $http call , the data structure retrieved is something in the following lines:-
[
{
"_id":"54e231b45f353d5c25cc4c30",
"staff_email":"aash_comm@rediffmail.com",
"staff_name":"Aarti Gupta",
"staff_address":"South Ex., Delhi",
"school":"54e2318d5f353d5c25cc4c0b",
"staff_designation":"",
"staff_mobile_no":"",
"staff_gender":"Female",
"staff_dob":"7-Jan-1984",
"staff_sum":"",
"__v":0,
"staff_is_classteacher":false,
"staff_classes":[
{
"_id":"54e231a25f353d5c25cc4c1f",
"class_name":"Class VI",
"class_section":"B"
},
{
"_id":"54e231a25f353d5c25cc4c1d",
"class_name":"Class VII",
"class_section":"C"
}
]
},
{
"_id":"54e231b55f353d5c25cc4c31",
"staff_email":"aishwaryataneja@gmail.com",
"staff_name":"AISHWARYA TANEJA",
"staff_address":"2356/4, KAROL BAG, NEW DELHI",
"school":"54e2318d5f353d5c25cc4c0b",
"staff_designation":"",
"staff_mobile_no":"",
"staff_gender":"Female",
"staff_dob":"21-Sep-1983",
"staff_sum":"",
"__v":0,
"staff_is_classteacher":false,
"staff_classes":[
{
"_id":"54e231a25f353d5c25cc4c1d",
"class_name":"Class VII",
"class_section":"C"
}
]
}
]
ok so as is evident from the dataset it is basically an array containing details of teachers and the classes taught by them. Filling the 1st select with the name of the teachers is easy using ng-options, same goes for the 2md select which will be populated the listing of classes as mentioned in the data-set.
My pain area is that i want to change the data in the 2nd select based on the option chosen in the 1st select, i have tried using a function on the ng-change of the 1st select but the 2nd select does not get filled with relevant data.
In a nutshell if the 1st select contains teacher1 and teacher1 teaches class1 & class2 then the 2nd select should just display class1 & class2 , and then if the selection in the 1st select changes from teacher1 to teacher2 and teacher2 teaches class3 & class4 then the 2nd select should display only class3 & class4 and so on..
TIA