0

I write simple factory which call to my rest endpont, but I would like use different address not only one, but when I execute query from $resource I get only text function in my console log.

This is my factory:

angular.module('blogfontApp.services', []).factory('Blog', function ($resource) {

    return {
      getAll : function () {
          return $resource('http://localhost:8080/api/blog');
      }
    }

});

and my controller:

angular.module('blogfontApp.controllers', []).controller('BlogListController',

  function ($scope, Blog ) {

      $scope.bloglist = Blog.getAll.query();


      console.log($scope.bloglist);

  });

How to call to different address from my factory?

1
  • Not really clear what you are asking Commented Nov 19, 2016 at 19:02

1 Answer 1

1

Try below using promise-

iApp.controller('TestController', function($scope, Blog) {
  Blog.getAll().query().$promise.then(function(result) {
    //success
    $scope.bloglist = result;
    console.log($scope.bloglist);
  }, function(errResponse) {
    // fail
  });
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.