0

My Input decorator looks like this

    @Input()
   filler(itemName:any,itemRate:number,itemQty:number,itemDiscount:number,itemSubtotal:number)
{
 this.cart.push({name:itemName,rate:itemRate,qty:itemQty,discount:itemDiscount,subtotal:itemSubtotal});
  }

and the call looks like this

<app-bill [filler]="['Name','Rate', 'Qty', 'Discount', 'Subtotal']"></app-bill>

and I need to pass all those 5 values to the "filler()".

1 Answer 1

2

Create a object of that type and pass the values,

<app-bill [filler]="item"></app-bill>

where item is created from class which has all the fields

Item.ts

class Item {
    Name: string;
    Rate: number;
    Qty : number;
    Discount : number;
    SubTotal: number;
}

In your Catalog Component.ts

import { Item } from 'Item';

 export class CheckOutPageComponent{
 item : Item;
 ngOnInit() {
        item.Name = 'test';
        ,,,,,,assign rest of values here
 }
Sign up to request clarification or add additional context in comments.

4 Comments

where should I create that class and how do I use it
In your application
@KedarUdupa it should be in parent component
I have a "Bill Component" with a "@Input" decorator and a "Catalog Component" from which I need to send data to "Bill Component", I created a class in "Catalog Component" but it didn't work.If you could be more precise it would be really helpful..?!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.