cordova, ionic framework and angularJS - angular datafactory behaviour

I'm new to cordova, Ionic framework and angular and have hit a road block with using a factory .

my factory is setup as follows:

    angular.module('test.factories', ['ionic'])
.factory('dataFactory', function($http, $q, $timeout){
 dataFactory.getItems = function(search) {
  var deferred = $q.defer();
 //rest of code to get stuff from SB works fine

//an array used to push items to from sqlite3 tx.executeSql 
returnData = []; 
deferred.resolve(returnData);
return deferred.promise;
}
}

all that works just fine, I get data into my controller and if its a list the data renders just fine! using ng-repeat in the view

however, I can't access a specific item in the returned array

eg

dataFactory.getItems("name").then(function(results){
   $scope.results = results; //ng-repeat works fine with this
   var a1 = results[0]; //returns undefined
   for (var i=0;i<results.length;i++) { //doesn't enter the loop}
   console.log(results); //shows [{"item","value"}] - JSON.parse returns an error
   //chrome devtool bar shows it as an array, and I can drill down into the elements! so
  $scope.result = results[0]; //nothing is set
});

this is causing some confusion, and issues as in some instances only 1 item is returned, and I'd like to render specific properties in the view eg {{result.property}}

as I said, I'm very new to all these frameworks, so may have done something totally wrong with the factory etc, but it's bugging me now lol how can an array be and array, but not ?!?

any help would be most appreciated!

cheers guys

BAHHHHH rookie mistake!!!

In my factory I had placed deferred.resolve(data) in the wrong place, I've now added it below the row iteration in the tx.executesql success function and all is well!

thanks for trying Haki