我在 ng-repeat 中有两个按钮。我希望以下按钮显示我是否已经在关注该人,否则应显示关注按钮。
这两个 _.each 函数正在从另一个用户那里获取关注者信息
以下列表是我关注的人的列表
问题是,如果我将 ng-show 和 ng-hide followingButtonTab 设置为 true,它会对 ng-repeat 的所有实例执行此操作。我的问题是,我怎样才能影响 ng-repeat 的一个实例,以便 ng-show 和 ng-hide 会适当地改变。
谢谢你的帮助!
html
<div class="follofwingBox" ng-repeat="user in following">
<img class=" profile-img img-circle" ng-src="{{user.img}}" || src="Assets/usericon.png" alt="User Pic"/>
<div class="il">
<span>{{user.name}}</span></br>
<span>{{user.occupation}}</span></br>
</div>
<button class="follow-button text-uppercase btn btn-default btn-xs" ng-hide="followingButtonTab" ng-click="followTab()">Follow</button>
<button class="follow-button text-uppercase btn btn-default btn-xs" ng-show="followingButtonTab">Following</button>
</div>
控制器
$scope.following = []
_.each(currentUser.following, function(id) {
_.each(users, function(user) {
if (id.followingId === user.$id) {
$scope.following.push({
name: user.name,
img: user.img,
id: user.$id,
occupation: user.ocupation
})
$scope.followingLength = $scope.following.length
followingList.$loaded().then(function(followingList){
getitem = _.findWhere(followingList, {followingId : user.$id})
if(getitem)
{$scope.followingButtonTab = true}
})
}
})
})