I do choose two fields (month and origin
) in a form and submit it to an AngularJS
controller, i am using 1.3.13 version packaged with Ionic framework.
Watching a console.log
inside then
method the values are populated correctly.
The q.promisse
wich is returned have this value: [object, object]
.
The list of the HTML
template is not populated with the rigth expected values.
The values does not populate the PHP POST
variable in the PHP API
.
How can i populate the POST
data ???
In my template i do submit to search
method :
<form method="post" ng-controller="AcpSearchCtrl" ng-submit="search(data)">
<select name="month" ng-model="data.month">
<option value="01">January</option>
And in my controller o do use http.post
and a promisse
:
.controller('AcpSearchCtrl', function($scope, ApiAcpSearch, $ionicLoading, $timeout, $http, ApiAcpEndpoint, $q) {
$scope.search = function(data) {
$ionicLoading.show({
noBackdrop: false,
template: '<p>searching ...</p>'
});
var q = $q.defer();
$scope.formData = {};
$scope.submission = false;
var param = function(data) {
var returnString = '';
for (d in data){
if (data.hasOwnProperty(d))
returnString += d + '=' + data[d] + '&';
}
return returnString.slice( 0, returnString.length - 1 );
};
console.log('formData : '+$scope.formData);
return $http({
url:ApiAcpEndpoint.url,
data : param($scope.formData),
method : 'POST',
headers : {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
})
.then(function(data) {
q.resolve(data);
var acp = {};
acp.qdata = [ data ];
$scope.data = acp.qdata;
$ionicLoading.hide();
return q.promise;
});
}
})