Question

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>
Était-ce utile?

La solution

Try to use ng-if directive:

<div ng-if="session.username">{{session.username}}</div>

Autres conseils

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

false.toString();

The above results in string "false".

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top