I have been dealing with managed fields retrieved from a web server in the following format:
{
"fields":{
"relationshipStatus":[
{
"fieldId":4,
"name":"Committed"
},
{
"fieldId":2,
"name":"Dating"
},
{
"fieldId":6,
"name":"Engaged"
},
{
"fieldId":3,
"name":"Exclusive"
},
{
"fieldId":7,
"name":"Married"
},
{
"fieldId":8,
"name":"Open Relationship"
},
{
"fieldId":5,
"name":"Partnered"
},
{
"fieldId":1,
"name":"Single"
}
]
}
}
Recently, I encountered an issue where I needed to filter profiles based on the relationship status field. To achieve this, I utilized a drop-down selector that performs the filtering operation using the field name like so:
<select ng-model='$storage.filter.relationshipStatus'
ng-options="option.fieldId as option.name for option in managedFields.relationshipStatus"
ng-change="changeFilter('relationshipStatus')">
<option value="">Any Relationship Status</option>
In another instance, while viewing individual profiles in a template, I noticed that when attempting to display the relationship status using {{profile.relationshipStatus}}
, it returned a numerical value (e.g., 4 for Committed) instead of the actual string value. I am unsure how to modify the profile template to show the string representation (e.g., "Committed") instead of the numeric identifier. I've tried using
{{profile.relationshipStatus.value}}
without success and considered resorting to custom JavaScript logic to convert the numbers to strings such as {{profile.relationshipStatus | relationshipToString}}
. As someone who is relatively new to this, I'm struggling to find relevant examples or resources on data binding for guidance.
If anyone could offer some advice or point me in the right direction, I would greatly appreciate it. Thank you.