Имеется такой json:
[
{
"id": 1,
"seasons": [
{
"id": 1,
"price": 900.0,
]
],
"video": "http://127.0.0.1:8000/media/ananas_30_15ndF3z.mp4",
"title": "Серия три",
"description": "ывафыва",
"image": "./poster_DLEMCRd.jpg"
}
]
На ангуларе есть такой фильтр:
$scope.seasonFilter = function(series) {
if ($scope.seasonIncludes.length > 0) {
if ($.inArray(series.seasons.id, $scope.seasonIncludes) < 0) {
return null;
}
} else {
}
return $scope.series;
};
Ошибка здесь:
if ($.inArray(series.seasons.id, $scope.seasonIncludes) < 0)
TypeError: Cannot read property 'id' of undefined
Вот такой объект приходит:
[{id: 1, seasons: [{id: 1,…}], video: "http://127.0.0.1:8000/media/ananas_30_JYQk0Qf.mp4",…}]
0
:
{id: 1, seasons: [{id: 1,…}], video: "http://127.0.0.1:8000/media/ananas_30_JYQk0Qf.mp4",…}
description
:
"Первая серия"
id
:
1
image
:
"./cont-img_GAHtslK.jpg"
seasons
:
[{id: 1,…}]
0
:
{id: 1,…}
description
:
"Сезон первый"
id
:
1
image
:
"./body-bg_ur8GGCM.jpg"
price
:
"1000.25"
season_number
:
1
series
:
[{id: 1, title: "1 серия", video: "./ananas_30_JYQk0Qf.mp4", description: "Первая серия",…}]
show
:
[{id: 1, image: "http://127.0.0.1:8000/media/poster_tBeKJsn.jpg", preview: null, title: "ЧОП",…}]
title
:
"1 сезон"
title
:
"1 серия"
video
:
"http://127.0.0.1:8000/media/ananas_30_JYQk0Qf.mp4"