Sorry, "but it returns 'undefined'. Does response have to be in a specific 
format ?" refers to the response of

> $httpBackend.when("GET", 'services/users').respond(function (method, url, 
> data) { return [{Name:"Bob}];  })


On Monday, January 13, 2014 10:25:19 AM UTC-5, Evgeni T wrote:
>
> Trying to make it work for me, and have a few questions:
>
> I can get a response when I'm providing a raw object in respond function, 
> e.g. 
>
>  $httpBackend.when("GET", 'services/users').respond([{Name:"Bob}]) // this 
>> works fine
>
> but
>
>  $httpBackend.when("GET", 'services/users').respond(function (method, url, 
>> data) { return [{Name:"Bob}];  })
>
> doesn't work, even though then function gets evaluated. 
>
>
> That function in respond gets evaluated on app start (the whole thing is 
> configured in a run block), is there a way to make it evaluate on actual 
> request? The idea was to load responses via $http, something along the 
> lines of
>
> var responses = {};
>> $http.get("file/with/response.js").then(function(data){ responses.users = 
>> data.users; });
>>  $httpBackend.when("GET", 'services/users').respond(function (method, 
>> url, data) { return responses.users; )
>
>
> If I could do something like 
>
>  $httpBackend.when("GET", 'services/users').respond(function (method, url, 
>> data) { return $http.get("/my/url"); )
>
> that would be even better.
>
> but it returns 'undefined'. Does response have to be in a specific format ?
>
> Is there  a way to pass through from $httpBackend? E.g.
>
>  $httpBackend.when("GET", 'services/users').respond(function (method, url, 
>> data) {
>> if ($location.absUrl().contains("test")) return "test data";
>> else passthrough();
>> } )
>
>
>
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to