首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >AngularJS和Firebase -从数据库中获取特定值

AngularJS和Firebase -从数据库中获取特定值
EN

Stack Overflow用户
提问于 2018-06-17 23:21:10
回答 1查看 211关注 0票数 0

很抱歉打扰你,我已经彻底搜索过了,但我已经积极尝试解决这个问题超过20个小时了。我即将放弃使用angularjs和firebase。我就是想不通..

我尝试将数组中的数据库值添加到页面中。它适用于其他数据,但不适用于此。

我的firebase数据库:

我已经包括了免费下注相关的代码,这是所有的好,但博彩deatils只是不会工作。在数组中还有其他的博彩细节,我也只是想让它正常工作。

代码语言:javascript
复制
  myApp.controller('BetsController',
  ['$scope', '$rootScope', '$location', '$routeParams', '$firebaseObject', '$firebaseArray',
  function($scope, $rootScope, $location, $routeParams, $firebaseObject, $firebaseArray) {

    //Values passed throu routeparams are assigned to variables and then used to search the firebase database.

  var ref, freeBetList, test;
  $scope.whichoffer = $routeParams.oId;
  $scope.whichuser = $routeParams.uId;

  ref = firebase.database().ref()
    .child('users').child($scope.whichuser)
    .child('offers').child($scope.whichoffer)
    .child('freeBets');

  freeBetList = $firebaseArray(ref);
  $scope.freeBets = freeBetList;


  test = firebase.database().ref()
    .child('users').child($scope.whichuser)
    .child('offers');

//.child('offerbookie')
//  testing = $firebaseObject(test);
testing = $firebaseArray(test);
$scope.test = testing;
代码语言:javascript
复制
<div class="card meetings cf">
  <h2>Free Bets</h2>
  <div class="meeting" ng-repeat="(key, freeBets) in freeBets">
        <a href="#">
        <span class="text">{{freeBets.eventname}}</span>
      </a>
      <button class="btn btn-delete tooltip"
        ng-click="deleteOffer(key)"><span>Delete this offer</span></button>
      </div>
    </div>

    <div class="card meetings cf">
      <h2>Offer Details</h2>
      <div class="meeting" ng-repeat="(key, value) in test">
        <a href="#">
          <p>{{whichoffer.offerbookie}}</p>
        </a>
      </div>
    </div>

Console.log:

代码语言:javascript
复制
[]
​
"$$added": function added()
​
"$$error": function error()
​
"$$getKey": function getKey()
​
"$$moved": function moved()
​
"$$notify": function notify()
​
"$$process": function process()
​
"$$removed": function removed()
​
"$$updated": function updated()
​
"$add": function add()
​
"$destroy": function destroy()
​
"$getRecord": function getRecord()
​
"$indexFor": function indexFor()
​
"$keyAt": function keyAt()
​
"$loaded": function loaded()
​
"$ref": function ref()
​
"$remove": remove()
​​
length: 1
​​
name: "bound $remove"
​​
__proto__: function ()
​
"$resolved": true
​
"$save": function save()
​
"$watch": function watch()
​
0: Object { date: 1529091671870, offerbookie: "Coral", offermarket: "Betfair", … }
​
1: Object { date: 1529150480309, offerbookie: "SkyBet", offermarket: "Smarkets", … }
​
length: 2
​
__proto__: Array []
bets.js:42:4

我只想显示一个与$scope.whichoffer相关的Offerbookie值。

当前输出:

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50897988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档