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


i have json object below

{     "txt_inc_application": {         "ews": true,         "ewindow": true     },     "txt_inc_incidenttype": {         "brand damage": true,         "internal failure": true     } } 

and using angular.foreach values

$scope.filterformula=function() {     angular.foreach($scope.filters, function(filterobj , filterindex) {         angular.foreach(filterobj, function(value , key) {             console.log(value+"--"+key)         })     }) } 

how can "txt_inc_application" , "txt_inc_incidenttype" in loop?

also when call angular function in html below why getting executed twice?

{{filterformula()}} 

enter image description here

the first parameter iterator in foreach value , second key of object.

angular.foreach(objecttoiterate, function(value, key) {     /* key: value pairs */ }); 

in example, outer foreach actually:

angular.foreach($scope.filters, function(filterobj , filterkey)