How can I pass an array as Input() from the component template?

后端 未结 3 530
耶瑟儿~
耶瑟儿~ 2021-02-04 23:38

I need to pass an array of values to a component using binding, e.g.

@Component({
    selector: \'my-component\',
    template: \'
3条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 00:23

    You need to wrap the property with [] otherwise it is not processed by Angular at all:

    [data]="[1, 2, 'test']"
    

    Your example seems to set data from inside the component. This is not how binding works. What you can do with your component is to pass data from the outside to your component.

提交回复
热议问题