Function: Service()
function Service<T>(ctor: T, ctx: ClassDecoratorContext): T;
Defined in: src/DI/decorators/service.ts:24
Decorator to mark a class as a Service Only stores metadata - actual registration happens when container is created All services are bootstrapped eagerly during container bootstrap
Type Parameters
| Type Parameter |
|---|
T extends Constructor |
Parameters
| Parameter | Type |
|---|---|
ctor |
T |
ctx |
ClassDecoratorContext |
Returns
T
Example
@Service
class AuthService {
@Inject(HttpClient) http!: HttpClient;
async login(credentials: Credentials) {
return this.http.post('/auth/login', credentials);
}
}