I am trying to JSON parsing in AngularJS using $stateParams
in the controller below:
rerunApp.controller('rerunCategoryListCtrl', function($scope, $http, $stateParams) {
var stpNameCat = $stateParams.nameCat;
$http.get(JSON URI).success(function (data, status) {
var response = data.Items.stpNameCat;
console.log(response);
});
});
Here is the structure of my JSON data:
{
cacheFileUpdate: 1435651202,
- Items: {
+ newsProgram: [...],
+ entertainProgram: [...],
+ documentaryProgram: [...],
+ benefitProgram: [...],
+ kidsProgram: [...],
+ dramaProgram: [...],
+ oldProgram: [...],
+ etcProgram: [...]
}
}
When running the app, I am aiming to extract items based on the value of $stateParams
. For example, if $stateParams
is 'newsProgram', I want to retrieve items in newsProgram. However, I am encountering an error at data.Items.stpNameCat
. How can I resolve this issue or are there any alternative solutions? Thank you!