Let's say my API returns the following people
array:
var p1 = new Person("Alice");
var p2 = new Person("Bob");
p1.Sibling = p2;
p2.Sibling = p1;
var people = new[] { p1, p2 };
To avoid circular references, it outputs the following JSON:
[
{
"$id":"1",
"Name":"Alice",
"Sibling":{
"$id":"2",
"Name":"Bob",
"Sibling":{
"$ref":"1"
}
}
},
{
"$ref":"2"
}
]
However, Angular doesn't handle it. Instead, I end up with an array where the second object is just a literal object with a $ref
property.
Googling around, I see Angular just doesn't support this, but I imagine there must be some way to get it working.