I need help filtering a nested object in AngularJS. I have created a function to retrieve the proptypes
, and now I want to filter out objects where type1.value = false
.
JSON:
scope.States = {
"1": {
"Prop": {
"id": 1
},
"PropTypes": {
"Type1": {
"date": "2015-05-30T01:01:04",
"value": false,
"id": 1,
"name": "defautPompier"
},
"Type2": {
"date": "2015-05-30T01:01:04",
"value": true,
"id": 1,
"name": "Delestage"
}
},
"defaultsInstallations": ["defautPompier", "Delestage"]
}
}
Controller:
$scope.GetDefaultByInstallation = function(title) {
$scope.installationsStates = [];
var res;
$scope.result = [];
Object.keys($scope.States).forEach(function(key) {
var res = false;
angular.forEach($scope.States[key].PropTypes, function(value, cle) {
if ($scope.States[key].PropTypes[cle] == title) {
res = true;
}
}