數據庫提供以下JSON字符串。需要使用ng-repeat(兩列上的組)顯示數據
$scope.items = [
{"Name":"Michael","Region":"Canada","Subject":"Chemistry","Action":"Email"},
{"Name":"Michael","Region":"Canada","Subject":"Biology","Action":"Call"},
{"Name":"Kristen","Region":"USA","Subject":"Chemistry","Action":"Skype"},
{"Name":"Kristen","Region":"USA","Subject":"Physics","Action":"Email"},
{"Name":"Kristen","Region":"USA","Subject":"Chemistry","Action":"Call"},
{"Name":"Kristen","Region":"Europe","Subject":"Chemistry","Action":"Call"},
{"Name":"Kristen","Region":"Europe","Subject":"Biology","Action":"Call"}
];
目前顯示的數據如下圖所示:(使用ng-repeat
)
Name Region Subject Action Michael Canada Chemistry Email Michael Canada Biology Call Kristen USA Chemistry Skype Kristen USA Physics Email Kristen USA Chemistry Call Kristen Europe Chemistry Call Kristen Europe Biology Call
預期結果(表格式)
Name Region Subject Action Michael Canada Chemistry,Biology Email,Call Kristen USA Chemistry,Physics Skype,Email,Call Kristen Europe Chemistry,Biology Call
不明白如何使用ng-repeat
得到預期的結果(如圖所示以上)。
嗨GSerg,感謝格式化我的問題。我可以知道你是怎麼做到的嗎?你在哪裏得到「編輯」鏈接? – user3172224
[Angular ng-repeat有條件包裝元素(ng-repeat中的組項)]的重複項可能的副本(http://stackoverflow.com/questions/23493063/angular-ng-repeat-conditional-wrap-items-in- ng-repeat) – paulwasit
你不能單獨使用ng-repeat來做到這一點。您需要首先自己映射這些數據,以便將每個人的主題和操作結合起來 – charlietfl