javascript - Selecting field from array based on a value filter -


very new angular (and whole mean stack).

i have mongodb db collection so:

db.users({      username: "test1",      fname: "bob",      lname: "saget",      email: "test@test.com",      password: "12345",       status: [{          active: false,          "non-active": false,          suspended: true,          "un-confirmed": false,          banned: false      }]  }) 

i'm wishing print users screen. , have been doing success, so.

        <tr ng-repeat="user in users">             <td>{{user.username}}</td>             <td>{{user.fname + ' ' + user.lname}}</td>             <td>{{user.email}}</td>             <td>{{user.password}}</td>             <td></td>         </tr> 

my problem comes trying display field (not value) of status array based on boolean value. in example read 'suspended' 1 page rather 'true' (and bring true values - there one).

have become cross-eyed, there better db structure adhere type of functionality?

i've tried combinations of ng-if, , ng-repeat filter: {} options.

i can provide details if needed.

how guys go this?

many thanks

after getting users can go through them , update status this.

angular.foreach($scope.users, function(a, b){   var user = a;   var status = a.status[0]; // <-- because status array pick first one.   (var k in status) {     if (status.hasownproperty(k)) {       if (status[k]) { // <-- if status true key.         user.status = k; // <-- set user status object key.       }     }   } }); 

you can change user.status = k whatever wish, setting status overwrites status array.

working example -> http://jsbin.com/zarulo/1/edit?html,js,output

hope helps!


Comments

Popular posts from this blog

Java 3D LWJGL collision -

methods - python can't use function in submodule -

c# - ErrorThe type or namespace name 'AxWMPLib' could not be found (are you missing a using directive or an assembly reference?) -