I am making an app with AngularJS, PHP and SQLite3.
I am trying to make autocomplete to my app with angucomplete directive from here
This directive uses scope for storing autocomplete options:
$scope.countries = [
{name: 'Afghanistan'},
{name: 'Aland Islands'},
{name: 'Albania'},
];
Every item is stored in an object of array. The question is: when I insert data from input after selecting an item from autocomplete, instead of the name of country, I see the next value in database:
[object Object]
That is, whatever word I select, I get the same value in my field - [object Object]. But other values are pushed in database properly. The field where data is inserted has varchar data type. Data is pushed in SQLite with AJAX and PHP:
$http({
method: 'POST',
url: urlInsert,
data: thisData,
headers: {'Content-Type' : 'application/x-www-form-urlencoded'},
})
.success(function(data) {
if(_recordAddedSuccessfully(data)) {
$scope.items.push({
id : data.item.id,
item : data.item.item,
qty : data.item.qty,
type : data.item.type,
type_name : data.item.type_name,
done : data.item.done
});
$scope.clear();
}
})
After PHP processes data, it is encoded in json and inserted in database.
How to do so that data from $scope.countries
is inserted properly instead of data I get [object Object]
?