2
I’m using it as follows:
<ion-item *ngFor="let via of lines.daysOperations?.week?.tripA?.routes; let i = index" text-wrap (click)="toggleGroup(i+'i')"
[ngClass]="{active: isGroupShown(i+'i')}">
And you’re making this mistake:
Error: Uncaught (in Promise): Error: Cannot find a differ supporting Object '[Object Object]' of type 'Via Green Corner'. Ngfor only Supports Binding to Iterables such as Arrays. Error: Cannot find a differ supporting Object '[Object Object]' of type 'Via Green Corner'. Ngfor only Supports Binding to Iterables such as Arrays.
My object is like this:
{ outros itens ..., routes: {name: "lorem inpsum", schedules:{10:00, 11:00, 12:00}}}
How can I fix this ??
I put the operator elvis ?
but did not solve my problem.
The object is var Lines = { daysOperations: { week: { tripa: {Routes: { }} }}} ?
– Don't Panic
yes in this stream
– Manuela Valentim
Are your "Routes" an array? If so, is it the only array? ngFor only serves to iterate on arrays
– Gabriel Berlanda
I don’t understand your question.
– Manuela Valentim
Inside Routes I have: Routes: { name: "Lorem Inpsum" Schedules:{ 11:00, 12:00 } }
– Manuela Valentim
@Gabrielberlanda my Routes is an object, and inside it I have an array.
– Manuela Valentim
You should use ngFor in an array, on whom do you want to iterate? in Schedules? If yes you should change the end of your ngFor => *ngFor="Let via of Lines.daysOperations?. week?. tripa? .routes.Schedules"
– Gabriel Berlanda
ngFor expects an array to iterate, it will not iterate on an object...
– Gabriel Berlanda
My other question was whether all the levels you access are objects and only the last level is an array, because you have some objects with the name in plural, e.g., Lines and daysOperations
– Gabriel Berlanda
@Gabrielberlanda Actually today this Routes he is one, but the idea is several Routes... However I identified an error in the data model. I will check further, anything update the question.. Thank you for so far to all
– Manuela Valentim
Yes, in my view you have some levels there, and you should go iterating one by one until you reach the last
– Gabriel Berlanda
lines.daysOperations?.week?.tripA?.routes
is being accessed as an object, so returned'[object Object]'
, it is necessary to check whether this parameterroutes
is really an array to be iterated byngFor
– Gaspar