@Provider
export declare let Provider: (config: (Function | IProvider)[]) => (Class: any) => any;
This token is synonym to @Injectable but it has one extra feature you can add dependencies to services it self which will be instantiated only for that service not to it's provider declaration in module, controller, filter etc.
Usage:
@Injectable()
export class ServiceA {
// this service is delivered by dependency injection if is declared as module provider
// otherwise exception is thrown
// this service is "global" to its module
@Inject(ServiceB)
private service: ServiceB;
}
@Injectable()
export class ServiceB {
}
@Provider([ServiceB])
export class UserService {
// here service is instantiated only to this UserService wherever UserService is provided
// new ServiceB is initialized
@Inject(ServiceB)
private service: ServiceB;
}