我正在使用嵌套的ng-repeats来显示页面上的内容。嵌套的ng-repeat显示一个复选框,该复选框的选中状态应设置为ng-repeat中数据的布尔值。我使用ng-checked并传入一个真值,但是,无论值是什么,都会检查复选框。
我已将代码简化为显示行为jsFiddle的演示。
HTML
<div ng-app="myApp">
<div ng-controller="myController">
<div ng-repeat="item in myArray">
<h3>{{ $index }}. {{ item.title }}</h3>
<div ng-repeat="child in item.subArray">
<h4>({{ child.id }}). {{child.title}} </h4>
<input type="checkbox" ng-checked="child.result" />
<h6>Answer is: {{ child.result }}</h6>
</div>
</div>
</div>
</div>
的JavaScript
var myApp = angular.module('myApp', []);
function myController($scope) {
$scope.myArray = [
{ id: "1", title: "my array 1", subArray: [
{ id: "1", title: "my sub array 1", result: "false" },
{ id: "1", title: "my sub array 2", result: "true" },
{ id: "1", title: "my sub array 3", result: "false" },
{ id: "1", title: "my sub array 4", result: "true" },
{ id: "1", title: "my sub array 5", result: "false" }]
},
{ id: "1", title: "my array 2", subArray: [
{ id: "1", title: "my sub array 1", result: "true" },
{ id: "1", title: "my sub array 2", result: "false" },
{ id: "1", title: "my sub array 3", result: "true" },
{ id: "1", title: "my sub array 4", result: "false" },
{ id: "1", title: "my sub array 5", result: "true" }]
},
{
id: "1", title: "my array 3", subArray: [
{ id: "1", title: "my sub array 1", result: "false" },
{ id: "1", title: "my sub array 2", result: "false" },
{ id: "1", title: "my sub array 3", result: "true" },
{ id: "1", title: "my sub array 4", result: "false" },
{ id: "1", title: "my sub array 5", result: "false" }]
},
{
id: "1", title: "my array 4", subArray: [
{ id: "1", title: "my sub array 1", result: "true" },
{ id: "1", title: "my sub array 2", result: "false" },
{ id: "1", title: "my sub array 3", result: "false" },
{ id: "1", title: "my sub array 4", result: "false" },
{ id: "1", title: "my sub array 5", result: "true" }]
},
{
id: "1", title: "my array 5", subArray: [
{ id: "1", title: "my sub array 1", result: "true" },
{ id: "1", title: "my sub array 2", result: "true" },
{ id: "1", title: "my sub array 3", result: "false" },
{ id: "1", title: "my sub array 4", result: "true" },
{ id: "1", title: "my sub array 5", result: "true" }]
}
];
}
有人可以解释为什么会出现这种情况并帮助我理解如何纠正它吗?
答案 0 :(得分:1)
由于// Begin Search For Open Tickets on ZenDesk
$zendesk = new Zendesk(ZD_APIKEY, ZD_USER, ZD_SITE);
$data = $zendesk->call("/search.json?query=status<solved requester:a#3b4edcfgiyfms3bbgzeszjl3drdx1y1ikgffxn7zyattij6wehup6wkorkfgozlvnb5@email.email type:ticket", $create, "GET");
if ($data->results) {
$ticket_id = (string) $data->results[0]->id;
//Use the end-user's email address, not an agent's email address as is the case with all other API end-points.
$user_email = 'a#3b4edcfgiyfms3bbgzeszjl3drdx1y1ikgffxn7zyattij6wehup6wkorkfgozlvnb5@email.email';
$zendesk = new Zendesk(ZD_APIKEY, $user_email, ZD_SITE);
$update = json_encode(
array(
'request' =>
array(
'comment' => array(
'body' => $message,
)
)
));
$data = $zendesk->call("/requests/" . $ticket_id . ".json", $update, "PUT");
}else{
$zendesk = new Zendesk($apiKey, $user, $subDomain, $suffix = '.json', $test = false);
$arr = array("z_subject"=>substr($message, 6, 80),
"z_description"=>substr($message, 6, 500),
"z_recipient"=>"hello "."@EMAIL.EMAIL",
"z_name"=>"$address",
"z_requester"=>substr($address, 4, 80)."@EMAIL.EMAIL"
);
$create = json_encode(array('ticket' => array('subject' => $arr['z_subject'], 'description' => $arr['z_description'], 'requester' => array('name' => $arr['z_name'], 'email' => $arr['z_requester']))), JSON_FORCE_OBJECT);
$data = $zendesk->call("/tickets", $create, "POST"); $logger->WriteLog('End of Ticket');
}
为child.result
而非string
,因此条件始终为boolean
。
使用以下内容:
true