Well, I have a feature on my system that has a large interaction with the end user, I then opted to employ Angular.js .
My goal is to dynamically populate a array and when the user der submit I send such data via $ http.post () to an action on my server that will "parse" such an array for my object (Jackson-bound ).
But the problem is that I do not know how to accomplish this in a correct way, because I have 2 modals on my screen in which every time I press "Add" a list will be populated dynamically on the screen and such data will be included in that tree.
Below I have the tree of my object in which I want to add the data via angular.
customerData = {
"idCustomer":null,
"tenantId":null,
"birthDate":$scope.birthDate,
"email":$scope.email,
"firstName":$scope.firstName,
"gender":$scope.gender,
"lastName":$scope.lastName,
"document":{
"id":null,
"tenantId":null,
"rg":$scope.customerRg,
"cpf":$scope.customerCpf
},
"customerPhone":{
"id":null,
"tenantId":null,
"celPhone":$scope.customerCelPhone,
"homePhone":$scope.customerHomePhone,
"workPhone":$scope.customerWorkPhone
},
"passenger":null,
"customerAddress":{
"id":null,
"tenantId":null,
"cep":$scope.customerAddressCep,
"complement":$scope.customerAddressComplement,
"number":$scope.customerAddressNumber,
"quarter":$scope.customerAddressQuarter,
"street":$scope.customerAddressStreet,
"city":$scope.customerAddressCity,
"state":$scope.customerAddressState,
"country":null
},
"observations":$scope.observations,
"site":false,
"customerService":{
"id":null,
"tenantId":null,
"date": new Date.now(),
"averageBudget":null,
"situation":true,
"serviceItem":[{
}],
"history":[{
"id":null,
"tenantId":null,
"register": "Primeiro Atendimento",
}],
"serviceObservations": "Xpto"
}
};
For example I have a controller in which to add in the serviceItem data in list form:
app.controller('RequestedDestinationModalController', ['$scope', function($scope) {
$scope.addReqDestiantion = function(){
this.customerData.customerService.serviceItem.push({
"id":null,
"destination":$scope.destinationModalCtrl.destination,
"customerService":null,
"tenantId":null,
"valueNegotiated":$scope.destinationModalCtrl.valueNegotiated,
"saleType":$scope.destinationModalCtrl.saleType,
"departureDate":$scope.destinationModalCtrl.departureDate,
"arrivalDate":$scope.destinationModalCtrl.arrivalDate,
"seeIn":$scope.destinationModalCtrl.seeIn,
"requestedDestination":$scope.destinationModalCtrl.requestedDestination,
"negociationObservations":$scope.destinationModalCtrl.negociationObservations
});
};
}]);
But in the case I would need to leave my array which contains the keys of objects stored somewhere to respectively manipulate it. So what's the problem, how to manipulate the array via multiple controllers?