Why is `@input` decorator preferred over `inputs:[]`

前端 未结 2 1581
轮回少年
轮回少年 2021-01-21 10:23

There are two ways to define an input on a component:

@Component({
    inputs: [\'displayEntriesCount\'],
    ...
})
export class MyTable implements OnInit {
            


        
2条回答
  •  旧时难觅i
    2021-01-21 10:40

    It's somehow preferred by the style guide, but there are no strong arguments. Perhaps because the properties and methods are kept together with the binding. But your argument also is valid. Some prefer the one, some the other.

    If you prefer host: ... then just use it. It's still quite common.

提交回复
热议问题