Yep, if you have a $http object with cache set to false, your cache system will be ignored ;)
I don't know if it's the best solution ever, but it seems simple and in accordance with the principles of Angular (testability, modularity). Interceptors are just here to change request or response but, to my knowledge, you cannot make a function that update both request and response in a row. With a request interceptor, you can only change request config or prevent the request by returning a rejected promise. A response interceptor will not be helpful in this case either.. I think that a custom cache system is the best solution in this case. Regards, Charly. On Thursday, 10 July 2014 14:18:24 UTC+2, Francisc wrote: > > Hello, > > I would like to be able to intercept all AJAX calls made with $http > service to prevent the any XHR calls and respond with data from an Angular > service (for example). > So the data is in memory, not from a remote resource. > > I want to be able to to this at runtime at the switch of a button, e.g. > "Cut server communication ON / OFF". > > As far as I can see, HTTP request interceptors can only modify the config > object and return it, but cannot return actual data as response. > > How can this be achieved? > > Thank you. > -- 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/d/optout.
