Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs displaying boolean from object

I have recieved object from server and trying to display its fields in table. All fields are displaying well but boolean is always displaying as "no".

<tr ng-repeat="u in ctrl.users">
      <td><span ng-bind="u.id"></span></td>
      <td><span ng-bind="u.name"></span></td>
      <td><span ng-bind="u.age"></span></td>
      <td><span ng-bind="u.isAdmin ? 'yes' : 'no'"  ></span></td>
 </tr>

I was trying to add filter, but result was the same.

like image 618
Geha Avatar asked Oct 30 '22 07:10

Geha


1 Answers

Double check you have the property name right in code.

You can print the u object as json with

<pre>{{u | json}}</pre>

I'm pretty sure that if the value is in the database and isn't false or null, then you have the name wrong, and it's not isAdmin but something else.

EDIT: Looks like I was right and you were using the property name admin instead.

like image 60
CaffGeek Avatar answered Nov 08 '22 06:11

CaffGeek