Rendering a template for every element in a data stream - Infinite Lists



  • I have a stream of data which I want to display in a list. As the title shows, I want to render a template for every element in my data. Basically like the Twitter Interface tutorial but with a stream of incoming data.
    I see that one-lazy-repeat takes a template but how can I use delegate to modify the contents of this template with the data? Thank you

    <ons-list>
       <ons-lazy-repeat id="infinite-list">
         <ons-list-item>
           <p id="title"> </p>
           <img id="post_img" />
           <p id="author"> </p>
         </ons-list-item>
       </ons-lazy-repeat>
     </ons-list>

  • Onsen UI

    @Dipanshu-Juneja The template is passed on the second argument to createItemContent function. However, it’s an html element, not a string. A better way would be using ons.createElement('<ons-list-item>' + content + '</ons-list-item>') in createItemContent.


Log in to reply