Changing hardcoded array to a $http callback

i am wanting to change my service from a hardcoded static array to an array returned from a $http call. i have attempted to do this below however it does not work.

I can confirm the data returned from http is working and returns the correct data( i have taken the link out for the purpose of the question).

i am not getting an error message and therefore cannot give any further information at this point however what i would like to know is if i am doing this in the correct way.

banging my head against a wall for such a simple task at the moment....

hardcorded array:

.factory('Cards', function($http){
  var cardTypes = [
    {id: 1, USECASE_NAME: "Frank", USECASE_IMAGE: 'img/Frank.png', USECASE_DESC:"This is frank the bank card, He helps people all over the world make millions of transactions each year!", done: true },
    {id: 2, USECASE_NAME: "John Lewis", USECASE_IMAGE: 'img/JohnLewis.png', USECASE_DESC:"John Lewis is one of the biggest retailers in the United Kingdom with a very proud reputation", done: true },
    {id: 3, USECASE_NAME: "Generali", USECASE_IMAGE: 'img/Generali.png', USECASE_DESC:"Generali is the largest insurance company in Italy and arguably one of the biggest in Europe", done: true },

  ];
  return {
    all: function() {
      return cardTypes;
    }
  }

});

$http callback

.factory('Cards', function($http) {
    var cardTypes = {};

    $http.post("http://url", {
        "auth": "cats",
        "name": "Adam",
        "uuid": "fasfA"
    }).
    success(function(data, status, headers, config) {
        cardTypes = data;
    }).
    error(function(data, status, headers, config) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.
    });

    return {
        all: function() {
            return cardTypes;
        }
    }
});

Remember that .http() is an asynchronous call. So calling .all() directly after initalizing the factory will result in returning an empty object, because the post request is probably still pending when .all() is called.

I would recommend using a service (a factory is possible as well, but imo a service would fit better here) and returning the promise like:

this.getAll = function() {
    return $http.post("http://url",{"auth":"cats","name":"Adam","uuid": "fasfA" });
}

Then in your controller you can do this:

Cards.getAll().then(function(c){
     $scope.cards = c;
})