<div ng-controller="ctrl" >
<div class = "allcontent">
<div class="userCard" ng-repeat="d in data">
<img class="cardImage" src="../../public/assets/dota2.png">
<h3 class="cardUsername">{{d.username}}</h3>
<span class="cardDescription">{{d.description}}</span>
<div class="cardSocialIcons">
<a ng-show={{d.showEmail}}><img class="cardMail" src="../../public/assets/mail.png"></a>
<a target = "_blank" href={{d.facebook}} ng-show={{d.facebook}}><img class="cardMail" src="../../public/assets/facebook.png"></a>
<a target = "_blank" href={{d.steam}} ng-show={{d.steam}}><img class="cardMail" src="../../public/assets/steam.png"></a>
<a target = "_blank" href={{d.xbox}} ng-show= showXboxIcon({{d.xbox}}) ><img class="cardMail" src="../../public/assets/xbox.png"></a>
<a target = "_blank" href={{d.psn}} ng-show=showPsnIcon({{d.psn}}) ><img class="cardMail" src="../../public/assets/psn.png"></a>
</div>
</div>
</div>
</div>
</div>
<script>
function showXboxIcon(xbox) {
if (xbox != "" && xbox != null && xbox != undefined) {
return true;
}
else {
return false;
}
}
function showPsnIcon(psn) {
if (psn != "" && psn != null && psn != undefined) {
return true;
}
else {
return false;
}
</script>
我想显示一个与用户使用的游戏网络相关的图标,并在所述网络上显示指向其个人资料的链接,但前提是该用户在该网络上拥有该帐户。
在这种情况下:d.xbox
和d.psn
存在,因此应向用户显示图标。
情况并非如此,我犯了什么错误?
(绝大多数是一个简单的语法错误)
答案 0 :(得分:1)
不需要{{}}
所以更改为此ng-show="showXboxIcon(d.xbox)"