Search code examples
angularangular-materialmetronic

Pass parameter to child component Angular


When I pass object to child component from parent - it comes converted to string

<m-tank-add fuelTypes="{{this.fuelTypes}}" count="{{count}}"></m-tank-add>
 @Input() fuelTypes: Array<FuelTypeModel>;
 @Input() count: number;

count comes as "5" and fuelTypes as "[object Object],[object Object],[object Object],[object Object],[object Object]"

How can I pass parameters so they wouldn't be converted to string?


Solution

  • You should be using property binding through square brackets since with interpolation value is stringified:

    [fuelTypes]="fuelTypes"
    

    See also: