如何使用angularJS从服务器显示不同的img,我在帖子中有重复帖子,并且我想要检索他的头像的每个帖子;我想调用函数getImage(post.author.id)并检索他的头像
<ons-list-item class="list-item-container">
<div class="list-item-left">
<img ng-src="{{getImage(post.author.id)}}" class="avator">
</div>
<div class="list-item-right">
<div class="list-item-content">
<div class="name">{{post.author.name}}</div>
<!-- <div class="name" id="id-autore" > {{post.author.id}}</div> -->
<span class="desc">{{formatDate(post.date) | date:"dd/MM/yyyy"}}</span>
</div>
</div>
</ons-list-item>
</ons-list>
我的HTML:
default
我有这个错误: 未捕获的错误:[$ rootScope:infdig] 10 $ digest()迭代达成。中止!观察者在最近5次迭代中被解雇
答案 0 :(得分:0)
你可以这样做:
<ons-list-item class="list-item-container">
<div class="list-item-left">
<img ng-src="getImage(post.author.id)" class="avator">
</div>
<div class="list-item-right">
<div class="list-item-content">
<div class="name">{{post.author.name}}</div>
<!-- <div class="name" id="id-autore" > {{post.author.id}}</div> -->
<span class="desc">{{formatDate(post.date) | date:"dd/MM/yyyy"}}</span>
</div>
</div>
</ons-list-item>
</ons-list>