Nothing changes with ES6 / TypeScript classes. It is just syntactic sugar for JavaScript constructor functions.
Good options for using factory services can be clarified by the troubleshooting process.
Since service services are preferred for units with OOP flavoring:
class FooClass { static $inject = [...]; constructor(...) {} } app.service('foo', FooClass);
And value services are preferred for single units that are not built from classes and are not related to DI:
app.value('bar', 'bar'); app.value('Baz', BazClass);
factory services can be used for other cases. That is, when a service requires a DI and the return value cannot be easily constructed from a class - a function, primitive, an object that is returned from a function call:
app.factory('qux', ($q) => $q.all([...]));
estus source share