Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am using this code and unable to figure out how to populate the data form the database into an ionic list

$scope.selectAll = function() {
    $scope.allSessions= [];
    var query = "SELECT * FROM tb_sessions7";
    $cordovaSQLite.execute(db, query, []).then(function(res) {
        if(res.rows.length > 0) {
             console.log("SELECTED -> " + res.rows.item(0).name + " " + res.rows.item(0).amount);
             for (var i=0; i<res.rows.length; i++) {
                $scope.allSessions.push(res.rows.items(i).name);
                //console.log("data->"+$scope.allSessions);
             }
        } else {
            console.log("No results found");
        }
    }, function (err) {
        console.error(err);
    });
}
share|improve this question

finally i got solution

$scope.selectAll = function() {

    var query = "SELECT * FROM tb_sessions7";
    $cordovaSQLite.execute(db, query, []).then(function(res) {

        if(res.rows.length > 0) {
             console.log("SELECTED -> " + res.rows.item(0).id + " " + res.rows.item(0).s_id);
             for (var i=0; i<res.rows.length; i++) {

                $scope.allSessions.push({
                    id: res.rows.item(i).id,
                    s_id: res.rows.item(i).s_id,
                    name: res.rows.item(i).name,
                    amount: res.rows.item(i).amount,
                    total_sessions: res.rows.item(i).total_sessions,
                    commission: res.rows.item(i).commission,
                    total_order: res.rows.item(i).total_order,
                    created_date: res.rows.item(i).created_date,
                    last_edit: res.rows.item(i).last_edit
                    });

             }
        } else {
            console.log("No results found");
        }
    }, function (err) {
        console.error("error=>"+err);
    });
}

HTML

<ion-list>
  <ion-item ng-repeat="session in allSessions | filter: searchKey" href="#/app/session/{{session.id}}">
    <h3>{{session.id}} {{session.name}}</h3>
    <p>{{session.amount}}</p>
  </ion-item>
</ion-list>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.