0

i'm simply trying printing out a param value that is FALSE, and it prints out "false" as plain text, quite unbelievable... any clue ?

   $rootScope.session = {
                "username" : $window.localStorage['user_username'] || false,
                "id_user" : $window.localStorage['user_id'] || false,
                "token" : $window.localStorage['user_session_token']
            }
    //in view
    <div>{{session.username}}</div>
itsme
  • 48,972
  • 96
  • 224
  • 345

2 Answers2

3

Try to use ng-if directive:

<div ng-if="session.username">{{session.username}}</div>
Goodnickoff
  • 2,267
  • 1
  • 15
  • 14
2

Angular.js probably calls toString() on the printed values.

false.toString();

The above results in string "false".

mingos
  • 23,778
  • 12
  • 70
  • 107
  • No, Angular [calls](https://github.com/angular/angular.js/blob/master/src/ng/interpolate.js#L184) `toJson()` function. – dfsq Feb 18 '14 at 10:36
  • Indeed. The result is the same in this particular case though. – mingos Feb 18 '14 at 11:19