Using below JSON object need to show key.
{
'fieldLabel': 'LABEL',
'fieldName': 'TEST',
'fieldKey': 'TEST2'
}
Below are the conditions: 1. If got fieldName, fieldLabel, and fieldKey then need to show fieldLabel 2. If only received fieldLabel and fieldKey then need to show fieldLabel 3. If only received fieldKey and fieldName then need to show fieldName
function valueToBeDisplay(displayProp, objKey, field, htmlStr) { angular.forEach(field, function (value, key) { if (field.fieldLabel ? field.fieldLabel : field.fieldName) { htmlStr += formatLabel(field[key]); //formatLabel is other function } }); return htmlStr; }