我的观点是这样写的:
<ul class="commentslist cf">
<li class="cf" ng-repeat="(key,comment) in activity.comments">
<div class="comment">{{comment.name}}
<div class="buttons" ng-show="isPostedUser(activity.$id, key, currentUser)">
<button class="btn btn-delete tooltip"
confirmation-needed = "Are you sure you want to delete this activity?"
ng-click="deleteComment(activity.$id,key)">
<span>Delete this comment</span></button>
</div><!-- buttons -->
</div><!-- comment -->
</li>
</ul>
在与此视图关联的控制器中,有一个名为:
$scope.isPostedUser = function(actId, key, user) {
var refComment = new Firebase(FIREBASE_URL + "users/" + $scope.whichuser + "/activities/" + actId +
"/comments/" + key);
var commentObj = $firebase(refComment).$asObject();
commentObj.$bindTo($scope, "data").then(function() {
return $scope.data.giver === user.$id;
});
};
此函数的目的是仅显示删除按钮 isPostedUser 评估为真。我进行了测试,它确实评估为真,但它仍然不显示按钮。知道为什么吗?