У меня есть 2 API под названием teachers
и sessions
.
teachers
JSON Файл:
[
{
"teacherName": "Binky Alderwick",
"id": "01"
},
{
"teacherName": "Basilio Gregg",
"id": "02"
},
{
"teacherName": "Binky Alderwick",
"id": "03"
},
{
"teacherName": "Cole Moxom",
"id": "04"
}
]
sessions
JSON file:
[
{
"id":"001",
"sessionName": "Chemistry",
"notes": "Chemistry is the study of matter, its properties",
"teacherIds": ["01","03"]<==========
},
{
"id":"002",
"sessionName": "Physics",
"notes": "Physics is the natural science that studies matter and its motion ",
"teacherIds": ["02","04"]
},
{
"id":"003",
"sessionName": "Maths",
"notes": "Mathematics includes the study of such topics as quantity",
"teacherIds": ["01","04"]<=========
},
{
"id":"004",
"sessionName": "Biology",
"notes": "Biology is the natural science that studies life and living organisms",
"teacherIds": ["02","04"]
}
]
Теперь я показываю всех учителей в шаблоне так:
В сессий JSON, я упомянул teacherIDs , который является массивом, я хочу отобразить сеансы конкретного учителя на основе teacherID.
Для сессий ex(Химия и математика) содержит teacherID как (01), поэтому я хочу отобразить эти 2 занятия (Химия и математика) в Учитель 1 (я, Бинки Олдервик) Как это:
Я должен получить все свойства объекта session
на основе teacherId
.
Stackblitz DEMO