I am encountering an issue with my code.
Below is the factory code:
.factory('shareDataService', function() {
var sharedData = {};
sharedData.shareData = function(dateFrom, dateTo) {
var from = dateFrom;
var to = dateTo;
alert(from + to);
};
return sharedData;
})
And this is the controller:
.controller('getFormDataCtrl', ['$rootScope','$scope', '$http', 'shareDataService', function ($rootScope,$scope, $http, shareDataService) {
$scope.getFromBase = function () {
shareDataService.shareData($scope.dateFrom, $scope.dateTo)
}
$scope.bookingFormSubmit = function (){
var array = {
"from": ''// i want put dateFrom HERE,
"to": '',// i want put dateTo HERE
"yacht": $rootScope.yacht_id,
"customer": {
"fistname": $scope.firstname,
"lastname": $scope.lastname,
"birthday": $scope.birthday,
"phone": $scope.phone,
"email": $scope.email,
"country": $scope.country,
"city": $scope.city
}
}
}}])
This page is developed using Symfony2 and Symfony2 forms. The initial form allows customers to select a start date and end date, with a button labeled "getFromBase()".
I aim to store this data in order to utilize it at a later time.
The subsequent form is displayed in another UI view. Here, customers input their personal details (such as name, last name, etc.). Upon clicking "bookingFormSubmit()", I retrieve all the data from this form. I also need to incorporate the data from the factory (the two variables) to create a JSON object.