In my main ng-repeat div I have one div which should only contain a single matching value, what I tried now causes the same value to appear in every game because it is in the main ng repeat, what should I do instead of
<div class="row spacing10" ng-controller="latestfeed">
<div class="col s1 offset-s11 time" ng-repeat="latest in latestfeed">{{ latest.minute }}</div>
</div>
to only get the minute of the event for the matching game?
HTML:
<div id="live" class="container" ng-controller="games">
<div ng-repeat="game in games">
<div class="card-panel">
<div class="row spacing10">
<div class="col s11" ng-class="{'bold': game.firstscore > game.secondscore}">{{ game.first}}</div>
<div class="col s1 customred" ng-class="{'customgreen': game.second > game.second}">{{ game.first|| 0 }}</div>
</div>
<div class="row spacing10" ng-controller="latestfeed">
<div class="col s1 offset-s11 time" ng-repeat="latest in latestfeed">{{ latest.minute }}</div>
</div>
<div class="row">
<div class="col s11" ng-class="{'bold': game.second> game.first }">{{ game.second}}</div>
<div class="col s1 customred" ng-class="{'customgreen': game.secondscore > game.firstscore }">{{ game.secondscore|| 0 }}</div>
</div>
</div>
</div>
</div>
app.js
app.controller('games', function ($scope, $http) {
$http.get('https://www.website.com/app/?data=games').success(function (data) {
$scope.games= data;
});
});
app.controller('latestfeed', function ($scope, $http) {
$http.get('https://www.website.com/app/?data=latestfeed').success(function (data) {
$scope.latestfeed = data;
});
});
PHP JSON queries:
games:
$sql->query('SELECT * FROM games WHERE dateofgame = :date');
latestfeed:
$sql->query('SELECT * FROM event_items, feed, games
WHERE event_items.event_id = feed.event_id
AND feed.gamenumber = games.gamenumber
AND day = :date
ORDER BY feed.time DESC LIMIT 1');
games query output in short:
[{"gamenumber":6160,"},{"gamenumber":6161,"}]
latestfeed query output in short:
[{"event_id":4,"gamenumber":6160,"minute":40,"}]
HTML output: One div contains gamenumber 6160 and one div contains gamenumber 6161, the minute 40 should only display in the first div in this case