gpt4 book ai didi

javascript - ng-checked 为 true 但未启用?

转载 作者:行者123 更新时间:2023-11-28 07:23:11 25 4
gpt4 key购买 nike

我的数据看起来像,其中每个条目都是来自 SupportServicelog

var getDummyLogsForNow = function () {
return [
{
"fileName": "file A",
"location": "logs/fileA",
"size": "20000",
"lastUpdated": "May 04, 2015 09:21PM"
},
{
"fileName": "file B",
"location": "logs/fileB",
"size": "4034300",
"lastUpdated": "May 01, 2015 01:21PM"
},
{
"fileName": "file C",
"location": "logs/fileC",
"size": "53437000",
"lastUpdated": "May 02, 2015 03:11PM"
}
]
};

return {
logs: getDummyLogsForNow()
};

在我的 Controller 中,我将其用作

$scope.logs = SupportService.logs;
$scope.selectedLogs = ["file C"];

这就是我在 HTML 表格上打印它们的方式

    <table class="logsTable">
<thead>
<tr>
<th>#</th>
<th>File Name</th>
<th>Last Updated</th>
<th>Size</th>
<th>Location</th>
</tr>
</thead>
<tr ng-repeat="log in logs">
<td>
<input type="checkbox"
ng-checked="selectedLogs.indexOf(log.fileName) != -1"
ng-click="toggleSelect(log)">
</td>
<td>{{log.fileName}}</td>
<td>{{log.lastUpdated}}</td>
<td>{{log.size}}</td>
<!--<td>{{log.location}}</td>-->
<td>{{selectedLogs.indexOf(log.fileName) != -1}}</td>
</tr>
</table>

即使其中一个条目为true复选框也不会被选中。我所看到的只是

enter image description here

这里有什么问题吗?

最佳答案

我认为您引用模型时可能有问题。我简化了您的示例(删除了服务)并在此处提供了一个工作示例:https://jsfiddle.net/fpnte4td/6/

所以 Controller 或服务中肯定有某些东西...您可以尝试直接在 Controller 中定义示例数据,如下所示?

$scope.logs = [{
"fileName": "file A",
"location": "logs/fileA",
"size": "20000",
"lastUpdated": "May 04, 2015 09:21PM"
},{
"fileName": "file B",
"location": "logs/fileB",
"size": "4034300",
"lastUpdated": "May 01, 2015 01:21PM"
},{
"fileName": "file C",
"location": "logs/fileC",
"size": "53437000",
"lastUpdated": "May 02, 2015 03:11PM"
}
];

如果这没有帮助,请发布服务和 Controller 的完整内容(跳过不相关的部分)

关于javascript - ng-checked 为 true 但未启用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30055062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com