更加简便的注入方法,不用事先声明及使用this来赋值

This commit is contained in:
Jeremy Yin 2019-06-18 21:27:42 +08:00
parent 4ee0b7210b
commit 71a16606db
1 changed files with 1 additions and 5 deletions

View File

@ -5,12 +5,8 @@ import { DemoService } from './providers/demo/demo.service'
@Controller('posts')
export class PostsController {
private readonly demoService;
constructor(demoService: DemoService) {
this.demoService = demoService
}
constructor(private readonly demoService: DemoService) {}
@Get()
index() {