Try to use ng-if
directive:
<div ng-if="session.username">{{session.username}}</div>
题
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>
解决方案
Try to use ng-if
directive:
<div ng-if="session.username">{{session.username}}</div>
其他提示
Angular.js probably calls toString()
on the printed values.
false.toString();
The above results in string "false"
.