// book.module.ts 注入
providers: [
{
provide: 'Category',
useValue: ['武侠', '修仙', '都市'],
},
],
// book.controller.ts 使用
constructor(@Inject('Category') private categorys: string[]) {}
@Get('/category')
getCategorys(): string[] {
return this.categorys;
}
Nest.js自定义注入
于 2024-04-06 22:44:57 首次发布