将参数传递给子组件Angular

问题描述 投票:0回答:1

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

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

如何传递参数以便它们不会转换为字符串?

angular angular-material metronic
1个回答
2
投票

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

[fuelTypes]="fuelTypes"

也可以看看:

© www.soinside.com 2019 - 2024. All rights reserved.