Ng-Repeat array to rows and columns

前端 未结 5 1892
梦谈多话
梦谈多话 2021-02-04 06:45

Thanks for taking the time to read this, I was wondering how I might be able to use ng-repeat to create a grid like box of options. I would like to take an array repeat nth num

5条回答
  •  遇见更好的自我
    2021-02-04 07:32

    I find it easier to simply use ng-repeat combined with ng-if and offsetting any indexes using $index. Mind the jade below:

    div(ng-repeat="product in products")
        div.row(ng-if="$index % 2 === 0")
          div.col(ng-init="p1 = products[$index]")
              span p1.Title
          div.col(ng-if="products.length > $index + 1", ng-init="p2 = products[$index + 1]")
              span p2.Title
          div.col(ng-if="products.length <= $index + 1")
    

提交回复
热议问题