gpt4 book ai didi

javascript - 如何将对象数组分配给数组?

转载 作者:行者123 更新时间:2023-12-03 07:23:46 24 4
gpt4 key购买 nike

我有一个来自后端的 json 响应 controlOwners 现在我想将响应设置为 $scope.selectedOwners = [] ,但它在控制台中给了我 undefined 任何想法这里出了问题吗?

ctrl.js

$scope.selectedOwners = [];
if ($state.is('app.editControl')) {
$scope.selectedOwners = angular.copy($scope.controlowners);
console.log('EDIT CONTROL OWNERS DATA', $scope.selectedOwners);
}

json.js

"controlOwners": [{
"workerKey": -1093,
"sourceFeed": null,
"statusLookUpCode": null,
"externalId": null,
"createdUserText": null,
"createdTimestamp": null,
"modifiedUserText": null,
"modifiedTimestamp": null,
"stdId": "ZK84T1N",
"ccId": null,
"empClasId": null,
"deptId": null,
"fullName": "Rajasekaran, Shanmuga",
}],

最佳答案

我的猜测是,正如我在上面的评论中所述,您对 controlOwners 的引用中的大小写不正确。您用小写的“o”(“controlowners”)拼写了它,而它应该是大写的“o”(“controlOwners”)。因此你会得到一个未定义的错误。

关于javascript - 如何将对象数组分配给数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36094343/

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