简体   繁体   English

Angular如何与离子一起使用ng-repeat

[英]Angular how to use ng-repeat with ionic

in ionic there is this demo 在离子中有这个演示

<ion-list>
  <ion-item ng-repeat="playlist in playlists" href="#/app/playlists/{{playlist.id}}">
    {{playlist.title}}
  </ion-item>
</ion-list>

But I'm using using ioic-material and I want to repeat this 但是我正在使用ioic-material,我想重复一遍

<a ng-repeat="shop in shops" href="#/app/shops" class="item item-thumbnail-left item-icon-right"  > 
                <img ng-src="{{img}}">
                <h2>{{title}}</h2>
                <p>{{subtitle}}</p></a>

and here is the shops $scope.shops = [ { title: 'shop1', id: 1 , subtitle: 'Sport , Casual, Suits' , img: "img/material3.jpg.jpg"}, { title: 'shop2', id: 2 , subtitle: 'Suits & Shoes, ' , img: "img/material3.jpg.jpg"},
];
这是商店$scope.shops = [ { title: 'shop1', id: 1 , subtitle: 'Sport , Casual, Suits' , img: "img/material3.jpg.jpg"}, { title: 'shop2', id: 2 , subtitle: 'Suits & Shoes, ' , img: "img/material3.jpg.jpg"},
];
$scope.shops = [ { title: 'shop1', id: 1 , subtitle: 'Sport , Casual, Suits' , img: "img/material3.jpg.jpg"}, { title: 'shop2', id: 2 , subtitle: 'Suits & Shoes, ' , img: "img/material3.jpg.jpg"},
];
but the generated HTML I got. 但是我得到了生成的HTML。 (no errors) (无错误)

<div class="list">

    <!-- ngRepeat: shop in shops --><a ng-repeat="shop in shops" href="#/app/shops" class="item item-thumbnail-left item-icon-right">
                <img>
                <h2 class="ng-binding"></h2>
                <p class="ng-binding"></p>
                </a><!-- end ngRepeat: shop in shops --><a ng-repeat="shop in shops" href="#/app/shops" class="item item-thumbnail-left item-icon-right">
                <img>
                <h2 class="ng-binding"></h2>
                <p class="ng-binding"></p>
                </a><!-- end ngRepeat: shop in shops -->
        </div>

So what I'm doing wrong ? 那我做错了什么?

got it I should do : 知道了,我应该做:

<a ng-repeat="shop in shops" href="#/app/shops" class="item item-thumbnail-left item-icon-right"  >
                <img ng-src="{{shop.img}}">
                <h2>{{shop.title}}</h2>
                <p>{{shop.subtitle}}</p>
                </a>


instead of 代替

<a ng-repeat="shop in shops" href="#/app/shops" class="item item-thumbnail-left item-icon-right"  > 
            <img ng-src="{{img}}">
            <h2>{{title}}</h2>
            <p>{{subtitle}}</p></a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM