Often times I want to deal with both arrays and single objects in the same fashion. For example I have the property of an object that can either be an array or just a string (look at the scale property):
[
{
"name": "Experiment type14",
"id": "00000000014",
"scale": ["Whole Brain", "Cell"],
},
{
"name": "Experiment type15",
"id": "00000000015",
"scale": "Cell",
}
]
What I want is to show my scale like here:
<span ng-repeat="scale in experimentType.scale">
<!--some decoration here--> {{scale}}
</span>
Of course this won't work for a single string values. Is there any elegant way not to worry whether I'm dealing with a string or with an array?
$()and forget about the object/array worries.