@@ -242,20 +242,20 @@ The `useFactory` syntax allows for creating providers **dynamically**. The actua
242
242
@@filename ()
243
243
const connectionProvider = {
244
244
provide: ' CONNECTION' ,
245
- useFactory : (optionsProvider : OptionsProvider , optionalProvider ? : string ) => {
245
+ useFactory : (optionsProvider : MyOptionsProvider , optionalProvider ? : string ) => {
246
246
const options = optionsProvider .get ();
247
247
return new DatabaseConnection (options );
248
248
},
249
- inject: [OptionsProvider , { token: ' SomeOptionalProvider' , optional: true }],
250
- // \_____________/ \__________________/
251
- // This provider The provider with this
252
- // is mandatory. token can resolve to `undefined`.
249
+ inject: [MyOptionsProvider , { token: ' SomeOptionalProvider' , optional: true }],
250
+ // \______________/ \__________________/
251
+ // This provider The provider with this token
252
+ // is mandatory. can resolve to `undefined`.
253
253
};
254
254
255
255
@Module ({
256
256
providers: [
257
257
connectionProvider ,
258
- OptionsProvider ,
258
+ MyOptionsProvider , // class-based provider
259
259
// { provide: 'SomeOptionalProvider', useValue: 'anything' },
260
260
],
261
261
})
@@ -267,16 +267,16 @@ const connectionProvider = {
267
267
const options = optionsProvider .get ();
268
268
return new DatabaseConnection (options );
269
269
},
270
- inject: [OptionsProvider , { token: ' SomeOptionalProvider' , optional: true }],
271
- // \_____________ / \__________________/
272
- // This provider The provider with this
273
- // is mandatory. token can resolve to `undefined`.
270
+ inject: [MyOptionsProvider , { token: ' SomeOptionalProvider' , optional: true }],
271
+ // \______________ / \__________________/
272
+ // This provider The provider with this token
273
+ // is mandatory. can resolve to `undefined`.
274
274
};
275
275
276
276
@Module ({
277
277
providers: [
278
278
connectionProvider ,
279
- OptionsProvider ,
279
+ MyOptionsProvider , // class-base provider
280
280
// { provide: 'SomeOptionalProvider', useValue: 'anything' },
281
281
],
282
282
})
0 commit comments