将参数传递给子组件Angular

时间:2018-09-11 14:23:06

标签: angular angular-material metronic

当我从父对象将对象传递给子组件时-它会转换为字符串

<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]"

如何传递参数,以免将其转换为字符串?

1 个答案:

答案 0 :(得分:2)

您应该通过方括号使用属性绑定,因为插值的值是字符串化的:

[fuelTypes]="fuelTypes"

另请参阅: