私は、ネストされた ng-repeat が 2 つの配列を一緒に接続する最良の方法を見つけようとしています。これは私が利用できるデータです (非常に短い例)。
GameGenre Table
ID | Genre
1 | Action
2 | First Person Shooter
3 | Adventure
Game Table
ID | IDGenre | Name
1 | 1 | SpiderMan
2 | 1 | Batman
3 | 2 | Wolfenstein
4 | 3 | Just Cause
5 | 3 | Tomb Raider
6 | 3 | Indiana jones
だから私はそこに2つの配列を結合するための最良の方法(方法/断食方法)を探しているので、これを取得します
IDGameGenre 1 Holds: GAMEID1 and GameID2
IDGameGenre 2 Holds: GameID3
IDGameGenre 3 Holds: GameID4, GameID5, GAMEID6
これは私がこれまでに思いついたものです。最初に2つの配列を消費します:
コントローラーで:
$http({
method: 'Get',
url: http://URL/api/GameGenre/All"
})
.success(function (data) {
$scope.GameGenre= data;
});
$http({
method: 'Get',
url: http://URL/api/Game/All"
})
.success(function (data) {
$scope.Game= data;
});
$scope.getTheGame = function(ID) {
return Game.get({IDGenre: ID});
};
HTMLでは
<div class="listing" ng-repeat="Genre in GameGenre" ng-init='getTheGame(Genre.ID)'>
<div class="Game" ng-repeat="Game in getTheGame"></div>
</div>
しかし、私はこの2つの作業を得ることができないようです.2つの配列を最初に消費し、それらの両方をスコープに追加してから、情報をソートするにはどうすればよいでしょうか.