I am using API from a well known travel company and I am having this problem.
The problem is the response for roomAvailability
.
Now if certain hotel has only one Room Type
, it sends it as a Room
object rather than sending it as an array which otherwise it would send if there were multiple Room Types
Now in my template, I have a ng-repeat
like :
<div ng-repeat='room in Rooms'>
Do some stuff like room.RoomType
</div>
Now what happens is , when Room
is not an array , ng-repeat
fails as it doesn't iterate over the Room array
.
Now what I can do is have a scope variable canIterate
and repeat the code in my markup.
But is there a better way so that I can avoid this repeat of code in markup ?