Javascript 从Angularjs中的数组中检索数据并将其传递给id
我让视图将值传递给控制器,并将其存储到数组中。但之后我愿意获取数组中的值,并在update方法中将其传递到id的值中 这是我的 HTML 这里有人建议使用Javascript 从Angularjs中的数组中检索数据并将其传递给id,javascript,arrays,angularjs,Javascript,Arrays,Angularjs,我让视图将值传递给控制器,并将其存储到数组中。但之后我愿意获取数组中的值,并在update方法中将其传递到id的值中 这是我的 HTML 这里有人建议使用 {id : $scope.plateid[0].plate_id, 但这行不通 我像这样被困了一两天。请帮帮忙 您正在将值推送到对象,并试图以错误的方式访问它。我创造了一把小提琴来解释它 试试下面 $scope.plateid = []; $scope.inspectionData = {
{id : $scope.plateid[0].plate_id,
但这行不通
我像这样被困了一两天。请帮帮忙 您正在将值推送到对象,并试图以错误的方式访问它。我创造了一把小提琴来解释它 试试下面
$scope.plateid = [];
$scope.inspectionData = {
equipment_status_codes_id: 1,
plate_container_id: 1,
plate_container_slot: 21,
plate_quality_id: 1
}
PlatesFactory.query(function(plates)
{
$scope.plates = plates;
});
$scope.getSelectedPlateID = function(item)
{
$scope.plateid.push({
plate_id : item.id
});
console.log($scope.plateid[0]);
//alert(item.wafer_id)
}
// I have no clue what I am doing wrong here, but it just not working. I can't seem to update the object on the database
PlatesInspectionFactory.update( {id : $scope.plateid[0].plate_id}, $scope.inspectionData)
这不是问题所在,先生。我的PlatesInspectionFactory.update id有问题,它没有从plateid阵列接收id。感谢您的建议当您登录$scope.plateid[0]时,您会得到什么?我想这个问题和我上面提到的一样。我已经编辑了我的答案,在我有places PlatesInspection Factory.update{id:$scope.plateid[0].plate_id},$scope.inspectionData的函数getSelectedPlateID中检查它,结果成功了。但是现在我把它放进了一个函数`$scope.storePlatesInspection=函数{PlatesInspection Factory.update{id:$scope.plateid[0]},$scope.inspectionData,函数{//to something}`它不起作用了。你知道吗?我已经用一个函数更新了你的小提琴。我已经解决了第一部分。但是现在用一个函数它就不起作用了。谢谢。你提供的信息似乎不足以帮助你。这里我让小提琴模拟你的情况:。你能更新它使你的观点更清楚吗。@Dfr谢谢或者制作一个现场演示。我已经更新了一个名为storePlatesInspection的功能,但它不起作用。请你看一下。
{id : $scope.plateid[0].plate_id,
$scope.plateid = [];
$scope.inspectionData = {
equipment_status_codes_id: 1,
plate_container_id: 1,
plate_container_slot: 21,
plate_quality_id: 1
}
PlatesFactory.query(function(plates)
{
$scope.plates = plates;
});
$scope.getSelectedPlateID = function(item)
{
$scope.plateid.push({
plate_id : item.id
});
console.log($scope.plateid[0]);
//alert(item.wafer_id)
}
// I have no clue what I am doing wrong here, but it just not working. I can't seem to update the object on the database
PlatesInspectionFactory.update( {id : $scope.plateid[0].plate_id}, $scope.inspectionData)