search

Home  >  Q&A  >  body text

angular.js - Using two templates in Ionic list

The project is a news category, and the list contains two forms (mixed), one is in pure title form, and the other is in picture form (three pictures are displayed side by side). The data returned by the background has a field to identify the presentation form. How to distinguish and display it in ionic. The currently used <ion-item ng-repeat="item in items"> is stuck, please give me some advice.

How to use different templates according to the background during repeat?

PHPzPHPz2777 days ago548

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-05-15 17:07:41

    <p ng-if="items[0].type==1">
        <ion-item ng-repeat="item in items">...
    </p>
    <p ng-if="items[0].type==2">
        <ion-item ng-repeat="item in items">...
    </p>

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-15 17:07:41

    <ion-item ng-repeat="item in items">
        <p ng-if="items[0].type==1">
            {{items[0].title}}
        </p>
        <p ng-if="items[0].type==2">
            {{items[0].img}}
        </p>
    </ion-item>

    reply
    0
  • Cancelreply