1

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] ?

1
  • Can you show more of your code? (The HTML.) Commented Dec 29, 2015 at 5:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.