I am wondering how can I rewrite the following factory into a TypeScript code. Here is the original code:
app.factory('errorInterceptor', function ($q) {
return {
responseError: function (response) {
console.error("Error: " + response.statusText);
return $q.reject(response);
}
}
});
So far I've tried the following:
export class errorInterceptor {
constructor(private $q:ng.IQService) {
}
public responseError(response:any){
console.error("Error: " + response.statusText);
return this.$q.reject(response);
}
public static getFactory(){
return errorInterceptor;
}
}
app.factory('errorInterceptor',errorInterceptor.getFactory());
But I get the following error:
Provider 'errorInterceptor' must return a value from $get factory method.
Any ideas?