S
S
Seva2015-07-28 01:16:45
JavaScript
Seva, 2015-07-28 01:16:45

How to deal with arrays?

A query to the database returns an object in which each row is also an object.
You need one object so that its properties can be inferred from $scope in a loop.
I.e:

{
    0 {
        name: "Вася"
    },
    1 {
        name: "Петя"
    }
}

needs to be turned into
[
    {name: "Вася"},
    {name: "Петя"}
]

How to be? Thank you.
UPD:
$cordovaSQLite.execute(db, query).then(function(res) {
            var rows = [];
            for (i in res.rows) {
                rows.push(res.rows[i]);
            }
            console.log(rows);
        });

does not work.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question