var productarr: IprodList[] = [

    { "pId":"285", "productName":"Samsung Galaxy Note 7",
''productPrice":"59000","productAvailable":"Available" },
    { "pId":"286", "productName":"Samsung Galaxy Note 7",
''productPrice":"59000","productAvailable":"Available" }
];

When you are pushing data into the array,


let productarray= IprodList[];
let prodData =  {} as IprodList;
prodData.pId = 285;
prodData.prodctName = 'something';
...

productarray.push(prodData);



On Tue, 26 May, 2020, 5:38 am j_rough, <janis.ro...@gmail.com> wrote:

> The error is on pID. Error is "An index signature must have exactly 1
> parameter". I don't know how to correct the index but I need an array of
> products using Interface type. Thanks Very much,
>
> interface IprodList {
>    [ *pId*: string,productName: string,
> productPrice: numbproductAvailable: string]
> }
>   var product:IprodList[]=[285,'Samsung Galaxy Note 7', 59000,'Available'
> ];
>   product.push([286, 'Samsung Galaxy S6 Edge',53499,'Available']);
>   product.push([287,'Nokia Lumia 640XL',14990, 'Out of Stock']);
>
> --
> You received this message because you are subscribed to the Google Groups
> "Angular and AngularJS discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to angular+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/angular/5b93c11f-909d-4227-a7dc-b4dd6e01188f%40googlegroups.com
> <https://groups.google.com/d/msgid/angular/5b93c11f-909d-4227-a7dc-b4dd6e01188f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/CAMwM62y8FC3-Y-OHcMZVTz16niOC7LM-NzPtqEnwazwk%3DmtJXg%40mail.gmail.com.

Reply via email to