AngularJS にプロトタイプ ソリューションがあり、次のデータ構造で動作しています。
$scope.clients = [
{ client:"Client1", projects:[
{ project: "Project1", items:[
{ item: "This is the first item" },
{ item: "This is the second item" }
]},
{ project: "Project2", items:[
{ item: "This is the third item" },
{ item: "This is the fourth item" }
]}
]},
{ client:"Client2", projects:[
{ project: "Project4", items:[
{ item: "This is the fifth item" },
{ item: "This is the sixth item" }
]}
]}
];
バックエンドの実装を検討していますが、API が上記のネストされたデータ構造をクライアントに提供する必要があるのか、それともアイテムのフラットな構造を提供する必要があるのか 、AngularJS クライアント アプリがネストされた構造を作成する必要があるのか わかりません。API が提供するフラットな構造の例を次に示します。
[
{ client: "Client 1", project: "Project 1", item: "This is the first item." },
{ client: "Client 1", project: "Project 1", item: "This is the second item.", },
{ client: "Client 1", project: "Project 2", item: "This is the third item.", },
{ client: "Client 2", project: "Project 4", item: "This is the fourth item.", }
];
これに最適なアプローチは何ですか?また、API 設計に関する参考文献はありますか?