所以我有了这个,它会显示我需要的结果:
if (item.isPrivateToSubOrg == false){
因为我已经添加了它,它不再有效:
if (item.isPrivateToSubOrg == false && item.eventStatus == 'Published'){
我使用getJSON提取数据,它看起来像这样:
{
auth_result: true,
is_valid: false,
eventId: "80649f4b-437c-4e96-b79e-e02901f33c17",
orgId: "00000000-0000-0000-0000-000000000000",
subId: "00000000-0000-0000-0000-000000000000",
waiverId: "00000000-0000-0000-0000-000000000000",
waiverIdForThisEvent: "00000000-0000-0000-0000-000000000000",
orgName: "",
subName: "",
eventPIN: "",
eventTitle: "",
eventDescr: "",
eventLocation: "",
startUtc: "2050-01-01T00:00:00",
endUtc: "2050-01-01T00:00:00",
startLocal: "2050-01-01T00:00:00",
endLocal: "2050-01-01T00:00:00",
attendanceGoal: 0,
attendanceActual: 0,
eventBudget: 0,
eventCost: 0,
categoryId: "00000000-0000-0000-0000-000000000000",
categoryDescr: "",
questionCount: 0,
last_error_msg: "",
attendeeList: [ ],
eventStatusId: "33333333-3333-3333-3333-333333333333",
eventStatus: "Published",
canCheckIn: true,
isPrivateToSubOrg: false,
allowsGuestCheckIn: false,
enteredUserId: "00000000-0000-0000-0000-000000000000",
hasImage: false,
twitterID: "",
orgScannerType: "",
rsvpLink: "",
contactPerson: "",
contactEmail: ""
}
关于我做错了什么的想法?谢谢!
答案 0 :(得分:1)
不确定为什么会返回" false"对你来说,但对我而言似乎是正确的并且回归"真实"。请参阅jsfiddle http://jsfiddle.net/ZhM3H/
表达式:
(item.isPrivateToSubOrg == false && item.eventStatus == 'Published')
当我对您的示例数据进行尝试时,返回true。也许故障是在其他地方?
答案 1 :(得分:0)
你想要比较的布尔值似乎是个问题。在下面尝试jsfiddle:
代码下方有效:
var ex = {
name : "name",
boolVal : true
};
if (ex.name == "name" && ex.boolVal) {
console.log("Inside if");
} else {
console.log("Inside Else");
}
以下代码不起作用
var ex = {
name : "name",
boolVal : true
};
if (ex.name == "name" && ex.boolVal == true) {
console.log("Inside if");
} else {
console.log("Inside Else");
}