如下代码
希望大神能帮我深入普及知识
@Controller()
export class AppController {
// 2. 如果他是这么写的我可以理解
// private readonly appService: AppService
constructor(private readonly appService: AppService) {}
@Get('/hello')
getHello(): string {
// 1. 为什么在这里可以通过this访问appService
return this.appService.getHello();
}
}
就是一语法糖啊……
下面的是上面的简写,这有啥可深入普及的……