lukassz lukassz - 1 year ago 90
AngularJS Question

AngularJS function in factory call to query from $resource

I write simple factory which call to my rest endpont, but I would like use different address not only one, but when I execute

I get only text function in my console log.

This is my factory:

angular.module('', []).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();



How to call to different address from my factory?

Answer Source

Try below using promise-

iApp.controller('TestController', function($scope, Blog) {
  Blog.getAll().query().$promise.then(function(result) {
    $scope.bloglist = result;
  }, function(errResponse) {
    // fail
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download