[angularjs] Angular JS - angular.forEach - How to get key of the object?

I have JSON object like below

{
    "txt_inc_Application": {
        "EWS": true,
        "EWindow": true
    },
    "txt_inc_IncidentType": {
        "Brand Damage": true,
        "Internal failure": true
    }
}

And I am using angular.forEach to get the values

$scope.filterFormula=function() {
    angular.forEach($scope.filters, function(filterObj , filterIndex) {
        angular.forEach(filterObj, function(value , key) {
            console.log(value+"--"+key)
        })
    })
}

How can i get "txt_inc_Application" and "txt_inc_IncidentType" in the loop?

Also when call the angular function in html like below why it is getting executed twice?

{{filterFormula()}}

enter image description here

This question is related to angularjs

The answer is


var obj = {name: 'Krishna', gender: 'male'};
angular.forEach(obj, function(value, key) {
    console.log(key + ': ' + value);
});

yields the attributes of obj with their respective values:

name: Krishna
gender: male