I have two related entities (Expedition and Temperature) and I need to keep the temperature when I create a new expedition.
This is the code that I currently have:
angular.module('nowLocateApp').controller('ExpedicionDialogController',
['$scope', '$stateParams', '$uibModalInstance', 'entity', 'Expedicion', 'Camion', 'Delegacion',
function($scope, $stateParams, $uibModalInstance, entity, Expedicion, Camion, Delegacion,Temperatura) {
$scope.expedicion = entity;
$scope.camions = Camion.query();
$scope.delegacions = Delegacion.query();
$scope.load = function(id) {
Expedicion.get({id : id}, function(result) {
$scope.expedicion = result;
});
};
$scope.save = function () {
$scope.isSaving = true;
if ($scope.expedicion.id != null) {
Expedicion.update($scope.expedicion, onSaveSuccess, onSaveError);
} else {
Expedicion.save($scope.expedicion, onSaveSuccess, onSaveError);
$scope.temperatura.expedicion = $scope.expedicion.id;
$scope.temperatura.temperatura = 10;
Temperatura.save($scope.temperatura);
}
};
}]);
You can see in full code is my repository of GitHub, I hope you can help me.