How convert promise to object


I am new to ionic and trying to display JSON data from php server with ng-repeat

What I have done so far was to create factory in services.js and controller in controllers.js

Here is my factory

.factory(‘Items’, function($http){
var items = {};
getItems: function(){

  return $http.get("").then(function(response){
    items = response;
    return items;

And controller

.controller(‘ItemCtrl’, function($scope, Items){

$scope.itemslist = [];
$scope.itemslist = Items.getItems();


I tried several different ways to show the itemalist in ng-repeat and it did not work
After creating custom itemlist and testing it in controller ng-repeat was working fine so that it was the problem.

Only I found was that even factory returned object, the controller received as promise, not object. So ng-repeat couldn’t display data from promise

Could anyone tell me what I did wrong?


.getItems().then(function(items){ $scope.itemslist = items });


However, where should I put your answer? I tried it in controllers.js and it did not work