【发布时间】:2020-07-16 08:56:48
【问题描述】:
Loopback 框架的新手。
我来自 Angular 和 Java(Spring 框架),这样的模式很常见。
我将如何在 Loopback 中做类似的事情?
@bind({ scope: BindingScope.TRANSIENT })
export class EmailService {
constructor(
@service() public environmentService: EnvironmentService,
@service() public logger: LoggingService,
public transporter: Mail,
) {
this.setupMailClient()
}
}
这是我尝试上述方法时遇到的错误:
$ yarn start
yarn run v1.22.4
$ npm run build
> service-email@1.0.0 build /Users/clementoh/projects/service-email
> lb-tsc
$ node -r source-map-support/register .
Server is running at http://[::1]:3000/development/v1/emails
Try http://[::1]:3000/development/v1/emails/ping
Unhandled error in POST /verifications/email: 500 ResolutionError: The argument 'LoggingService.constructor[1]' is not decorated for dependency injection but no value was supplied by the caller. Did you forget to apply @inject() to the argument? (context: RequestContext-x2a2BH0zTmy5OlakULzpvw-3, resolutionPath: controllers.RemoteConfigController --> @RemoteConfigController.constructor[0] --> services.EmailService --> @EmailService.constructor[1] --> services.LoggingService)
【问题讨论】:
标签: loopback