I am facing an issue with passing values from the view to the controller and storing them in an array. My goal is to then retrieve a value from the array and pass it as the id value in the update method.
Here is my current setup:
HTML
<label class="control-label col-xs-8 col-sm-3 no-padding-right" >Choose a Plate</label>
<div class="col-xs-12 col-sm-9">
<select id="plateId" ng-model="selectedPlate" ng-options="plate as (plate.wafer_id + ' - ' + plate.serial_number) for plate in plates" ng-change="getSelectedPlateID(selectedPlate)"/>
<option value="">Select</option>
</select>
And this is my controller
$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]);
}
PlatesInspectionFactory.update({id : $scope.plateid[0]}, $scope.inspectionData)
Someone suggested using
{id : $scope.plateid[0].plate_id,
but unfortunately, this didn't work for me.
I've been stuck on this problem for a day or two now. Can someone please help?