【发布时间】:2015-08-07 01:23:03
【问题描述】:
我确定这是一个微不足道的问题,但似乎无法弄清楚如何访问这个 firebase 数组中的玩家 ID。我需要能够访问所有玩家 id,如果登录时建立的当前 users.id 与玩家 id 的 firebase 数组之一匹配,那么这些游戏将使用 ng-repeat 循环播放。我知道如何完成后者,我只是不知道如何访问唯一 ID 内的玩家 ID;希望这是有道理的。非常感谢任何帮助,谢谢。
JS
(这是与我的问题相关的一些代码)
game.controller('games.controller', ['$scope', '$state', '$stateParams', 'Auth', '$firebaseArray','Fire', function ($scope, $state, $stateParams, auth, $firebaseArray, fire) {
$scope.games = $firebaseArray(fire.child('games'));
$scope.view = 'listView';
$scope.setCurrentGame = function(game) {
$scope.currentGame = game;
};
$scope.createGame = function() {
if ($scope.format == 'Match Play') {
$scope.skinAmount = 'DOES NOT APPLY';
$scope.birdieAmount = 'DOES NOT APPLY';
}
$scope.games.$add({
name: $scope.gameName,
host: $scope.user.name,
date: $scope.gameDate,
location: {
course: $scope.courseName,
address: $scope.courseAddress
},
rules: {
amount: $scope.gameAmount,
perSkin: $scope.skinAmount,
perBirdie: $scope.birdieAmount,
format: $scope.format,
holes : $scope.holes,
time: $scope.time
}
})
$state.go('games');
};
$scope.addPlayer = function(game) {
$firebaseArray(fire.child('games').child(game.$id).child('players')).$add({
id : $scope.user.id,
name : $scope.user.name,
email : $scope.user.email
});
}
// swap DOM structure in games state
$scope.changeView = function(view){
$scope.view = view;
}
}]);
【问题讨论】:
标签: javascript angularjs firebase