In my ionic newbie adventures, I’ve come across a new obstacle:
I need to build the app’s main list from a sqlite database, so when the app loads, I need to read the table and populate my list (I assume that the best way to do so is reading the objects from the db into an array and using a ng-repeat that pulls from it).
The sqlite part is not the problem (I’m using the CordovaSQLite-plugin and I’ve managed to learn the basics of it), but since from my research I should not run any sqlite calls before the device is ready, I need to populate the array from .run
, within $ionicPlatform.ready
.
So, I have:
.controller('Ctrl', function($scope, $cordovaSQLite)
{
$scope.venues = [];
...
}
and
.run(function($ionicPlatform, $cordovaSQLite)
{
$ionicPlatform.ready(function()
{
//I need to populate $scope.venues from here, apparently.
...
}
}
in my html I have
<body ng-app="app" ng-controller="Ctrl">
...
<ion-item ng-repeat="venue in venues">
<div style="float:left">{{venue.name}}</div>
<div style="float:right">{{venue.location}} - {{venue.type}}</div>
</ion-item>
</body>
So that’s it, I don’t really know what to do from here to get the array populated.