When given a JSON array of objects, how can one dynamically display it using ng-repeat? The key error
is static and always remains the same. Only the values of error
change. For example, if the password field has an error, then the key will be password
in place of error
.
{
"error": {
"firstName": {
"0": "The first name field is required.",
"1": "The first name field must have 2-5 characters."
},
"lastName": {
"0": "The last name field is required."
}
}
}
.
{
"error": {
"password": {
"0": "The password field is required."
}
}
}
I attempted to do this:
<ul ng-repeat="message in errormessage">
<li ng-repeat="(k,v) in message">
{{k}} - {{v}}
</li>
</ul>
However, instead of the desired output, it displays:
0 - [
0 - ]