小编Ant*_*y D的帖子

访问firebase中的嵌套唯一键值

我确定这是一个微不足道的问题,但似乎无法弄清楚如何访问这个firebase数组中的玩家ID.我需要能够访问所有玩家ID,如果在登录时建立的当前users.id与其中一个玩家id的firebase阵列匹配,那么这些游戏将使用ng-repeat进行循环.我知道如何完成后者,我只是无法弄清楚访问唯一身份内的玩家身份; 希望这是有道理的.非常感谢任何帮助,谢谢.

火力地堡

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, …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs firebase

3
推荐指数
1
解决办法
2302
查看次数

如何在Ruby中反转链表

在下面的变异示例中,我不明白链接列表是如何反转的.

class LinkedListNode
  attr_accessor :value, :next_node

  def initialize(value, next_node=nil)
    @value = value
    @next_node = next_node
  end
end

def print_values(list_node)
  print "#{list_node.value} --> "
  if list_node.next_node.nil?
    print "nil\n"
    return
  else
    print_values(list_node.next_node)
  end
end
def reverse_list(list, previous=nil)
  current_head = list.next_node
  list.next_node = previous
  if current_head
    reverse_list(current_head, list)
  else
    list
  end
end

node1 = LinkedListNode.new(37)
node2 = LinkedListNode.new(99, node1)
node3 = LinkedListNode.new(12, node2)
print_values(node3)
puts "-------"
revlist = reverse_list(node3)
print_values(revlist)
Run Code Online (Sandbox Code Playgroud)

如果我回来current_head,我会得到99->37->nil,这是有道理的,因为99next_node.返回下一行,

list.next_node = previous
Run Code Online (Sandbox Code Playgroud)

抛出错误,因为 …

ruby linked-list

3
推荐指数
1
解决办法
2277
查看次数

标签 统计

angularjs ×1

firebase ×1

javascript ×1

linked-list ×1

ruby ×1