我有一个当前范围的用户,由我当前的控制器设置.
$scope.user = user;
不起作用: 作品: 发生了 我使用的 抛出异常: 如果我使用 我使用时,此错误消失 用户对象: 这是以下
dimirc..
6
请记住,ngShow期望一个表达式进行评估,并使用此函数将其"转换"为Boolean: https://github.com/angular/angular.js/blob/834d316829afdd0cc6a680f47d4c9b691edcc989/src/Angular.js#L962 所以你不应该只使用一个对象.你可以继续使用 请记住,ngShow期望一个表达式进行评估,并使用此函数将其"转换"为Boolean: https://github.com/angular/angular.js/blob/834d316829afdd0cc6a680f47d4c9b691edcc989/src/Angular.js#L962 所以你不应该只使用一个对象.你可以继续使用ng-show="user"
ng-show="!!user"
ng-show
什么导致ng-show="user"
不真实?angular.1.2.6
是https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.jsng-show="user"
,那么我在我的控制台中得到以下异常:TypeError: Cannot convert object to primitive value
at Ma (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js:14:240)
at Object.
ng-show="!!user"
user
对象$scope
:{
"state": "",
"access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"token_type": "Bearer",
"expires_in": "3600",
"code": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"scope": "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.moments.write https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.profile.agerange.read https://www.googleapis.com/auth/plus.profile.language.read https://www.googleapis.com/auth/plus.circles.members.read",
"id_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"authuser": "0",
"session_state": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"prompt": "none",
"client_id": "xxxxxxxxxxx.apps.googleusercontent.com",
"g_user_cookie_policy": "single_host_origin",
"cookie_policy": "single_host_origin",
"response_type": "code token id_token gsession",
"issued_at": "1391059385",
"expires_at": "1391062985",
"_aa": "0",
"status": {
"google_logged_in": true,
"signed_in": true,
"method": "AUTO"
}
}
function toBoolean(value) {
if (typeof value === 'function') {
value = true;
} else if (value && value.length !== 0) {
var v = lowercase("" + value);
value = !(v == 'f' || v == '0' || v == 'false' || v == 'no' || v == 'n' || v == '[]');
} else {
value = false;
}
return value;
}
!!user
或者也许user.someattr
function toBoolean(value) {
if (typeof value === 'function') {
value = true;
} else if (value && value.length !== 0) {
var v = lowercase("" + value);
value = !(v == 'f' || v == '0' || v == 'false' || v == 'no' || v == 'n' || v == '[]');
} else {
value = false;
}
return value;
}
!!user
或者也许user.someattr