Why isn't optional chaining working in this scenario?
.html
{{userItemModel?.item?.priceList[0]?.sellerUrl}}
An error is displayed:
TypeError: Cannot read property '0' of undefined
"@angular/core": "~10.1.1",
"typescript": "~4.0.2"
"priceList": [
{
"amount": 14.5,
"currency": "USD",
"sellerUrl": "https://www.bay.com/itm/Lear-6910-/33372049",
"basePrice": 15,
"discount": 10
}
],
Update
Use case 1:
Parser Error: Unexpected token [, expected identifier or keyword at column 33
in [{{userItemModel?.item?.priceList?.[0]?.sellerUrl}}] in
Use case 2:
Parser Error: Unexpected token [, expected identifier or keyword at column 33 in [
{{userItemModel?.item?.priceList?.[0].sellerUrl}}
] in