当我从父对象将对象传递给子组件时-它会转换为字符串
<m-tank-add fuelTypes="{{this.fuelTypes}}" count="{{count}}"></m-tank-add>
@Input() fuelTypes: Array<FuelTypeModel>;
@Input() count: number;
count
为"5"
,而fuelTypes
为"[object Object],[object Object],[object Object],[object Object],[object Object]"
如何传递参数,以免将其转换为字符串?
答案 0 :(得分:2)
您应该通过方括号使用属性绑定,因为插值的值是字符串化的:
[fuelTypes]="fuelTypes"
另请参阅: