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>
Was it helpful?

Solution

Try to use ng-if directive:

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

OTHER TIPS

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

false.toString();

The above results in string "false".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top