Looping section inside another looping section help

5 views
Skip to first unread message

Charuka Wijesinghe

unread,
Mar 21, 2017, 2:02:28 AM3/21/17
to JavaScript Templates Engine PURE
Hi Beebole 


Here is my requirement as follow i have data and template hotels list inside rooms list (only first room item will be taking for build template lowest rate room (assume first item is lowest one )) how can i achieve this using directive 
i already done with one section (hotel) i dont know how i iterate rooms list using pure js but not via function appreciate you help on this



<div class=hotel-section>
<span class="hotel-name"></span>
<span class="hotel-address"> </span>
<div class="rooms-section">
//only one section by getting 0th item of the list (only one room
showing per template ) 
<span class="room-name"> </span>
<span class="room-type"> </span>
<span class="room-rate"> </span>
</div>
</div>






json


var dataHotel =
[
{
"hotelName": "Hilton",
"hotelAddress": "Colombo 3",
"rooms": [

{
"roomname": "Single Delux",
"roomType": "Bed & BF",
"rate": "2400$"
},


{
"roomname": "Double Delux",
"roomType": "Bed Only",
"rate": "2400$"
}
]
},

{
"hotelName": "Grand Kandyan",
"hotelAddress": "Kandy"
}

]
 

Mic (BeeBole)

unread,
Mar 21, 2017, 5:58:00 AM3/21/17
to JavaScript Templates Engine PURE
Here is an example of something working: https://gist.github.com/beebole/78d3f3827bd2a4a426c6438ec5598f6b

I'm not sure I understood the first room thing, but here's what I did:

  • the sort function sorts the rooms by rate ascending. Sorting should always be a client thing, not on the server :)
  • the filter function shows only the first room
Cheers,
-Mic

Charuka Wijesinghe

unread,
Mar 24, 2017, 3:17:12 AM3/24/17
to JavaScript Templates Engine PURE
Thanks nice explanation 
Reply all
Reply to author
Forward
0 new messages