Hello.

I'm using an online API to get player data. The JSON response looks like 
this http://pastebin.com/PRbbR3yn
There is a root object called "servers" which contains 2 arrays. And the 
array contains attrs and one array called "players".

I mixed the two players arrays from different servers (server[0].players 
and server [1].players) and initialized them to one array which I use for 
ng-repeat to list the names.
My problem is I have 4 checkboxes on my website which should filter 
server1, server2, players and admins.

server1 = true, should show server1 players
server2 = true, should show server2 players
(When both are true the arrays should be mixed)
players = true, should show players.admin == false
admins = true, should show players.admin == true

This is how looks my code.

index.html
<input type="checkbox" ng-model="vm.checkbox.s1"> Server 1 ({{ 
vm.s1.mapname }})
<input type="checkbox" ng-model="vm.checkbox.s2"> Server 2 ({{ 
vm.s2.mapname }})
<input type="checkbox" ng-model="vm.checkbox.player"> Players
<input type="checkbox" ng-model="vm.checkbox.admin"> Admins

...
<li ng-if="vm.players.length" ng-repeat="player in vm.players | filter: 
search | orderBy: 'name'">
    <a ng-click="vm.userInfo(player.name)" href="#" ng-if="player.admin" 
class="admin-icon">{{ player.name }} ({{ player.id }})</a>
    <a ng-click="vm.userInfo(player.name)" href="#" 
ng-if="!player.admin">{{ player.name }} ({{ player.id }})</a>
</li>


core.js
$http.get("api/players.php")
    .then(function (res) {

        vm.s1 = res.data.servers[0];
        vm.s2 = res.data.servers[1];

        // to show all players in one list
        vm.players = vm.s1.players.concat(vm.s2.players);

        vm.loading = false;
    });

This shows all players but filter not working, because I dont know how to 
do it.



-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to