嵌套查询超过3个级别

时间:2016-12-27 00:03:13

标签: angular typescript firebase firebase-realtime-database angularfire2

我正在尝试使用此查询从Firebase返回结果:

    /***/ 782:
/***/ function(module, exports) {

module.exports = "/**\n * cbpAnimatedHeader.min.js v1.0.0\n * http://www.codrops.com\n *\n * Licensed under the MIT license.\n * http://www.opensource.org/licenses/mit-license.php\n * \n * Copyright 2013, Codrops\n * http://www.codrops.com\n */\nvar cbpAnimatedHeader=(function(){var b=document.documentElement,g=document.querySelector(\".cbp-af-header\"),e=false,a=300;function f(){window.addEventListener(\"scroll\",function(h){if(!e){e=true;setTimeout(d,250)}},false)}function d(){var h=c();if(h>=a){classie.add(g,\"cbp-af-header-shrink\")}else{classie.remove(g,\"cbp-af-header-shrink\")}e=false}function c(){return window.pageYOffset||b.scrollTop}f()})();"

/***/ },

/***/ 783:
/***/ function(module, exports) {

module.exports = "/*!\n * classie - class helper functions\n * from bonzo https://github.com/ded/bonzo\n * \n * classie.has( elem, 'my-class' ) -> true/false\n * classie.add( elem, 'my-new-class' )\n * classie.remove( elem, 'my-unwanted-class' )\n * classie.toggle( elem, 'my-class' )\n */\n\n/*jshint browser: true, strict: true, undef: true */\n/*global define: false */\n\n( function( window ) {\n\n'use strict';\n\n// class helper functions from bonzo https://github.com/ded/bonzo\n\nfunction classReg( className ) {\n  return new RegExp(\"(^|\\\\s+)\" + className + \"(\\\\s+|$)\");\n}\n\n// classList support for class management\n// altho to be fair, the api sucks because it won't accept multiple classes at once\nvar hasClass, addClass, removeClass;\n\nif ( 'classList' in document.documentElement ) {\n  hasClass = function( elem, c ) {\n    return elem.classList.contains( c );\n  };\n  addClass = function( elem, c ) {\n    elem.classList.add( c );\n  };\n  removeClass = function( elem, c ) {\n    elem.classList.remove( c );\n  };\n}\nelse {\n  hasClass = function( elem, c ) {\n    return classReg( c ).test( elem.className );\n  };\n  addClass = function( elem, c ) {\n    if ( !hasClass( elem, c ) ) {\n      elem.className = elem.className + ' ' + c;\n    }\n  };\n  removeClass = function( elem, c ) {\n    elem.className = elem.className.replace( classReg( c ), ' ' );\n  };\n}\n\nfunction toggleClass( elem, c ) {\n  var fn = hasClass( elem, c ) ? removeClass : addClass;\n  fn( elem, c );\n}\n\nvar classie = {\n  // full names\n  hasClass: hasClass,\n  addClass: addClass,\n  removeClass: removeClass,\n  toggleClass: toggleClass,\n  // short names\n  has: hasClass,\n  add: addClass,\n  remove: removeClass,\n  toggle: toggleClass\n};\n\n// transport\nif ( typeof define === 'function' && define.amd ) {\n  // AMD\n  define( classie );\n} else {\n  // browser global\n  window.classie = classie;\n}\n\n})( window );\n"

/***/ },

我不确定它是否应该做到它应该是什么,因为第二级已经是一个可以观察输出的观察点。

我在模板中使用此代码来获取数据:

  // Get all Tipps
  getAll(match: String): Observable<any> {
    let filter: Object = { query: { orderByChild: 'match', equalTo: match } };
    return this.loginService.af.database.list('/tipps/', filter).map((tipps) => {   
      return tipps.map((tipp) => { 
        tipp.matchsub = this.loginService.af.database.object("/matches/" + tipp.match).map((matches) => {
          return matches.map((match) => {
            match.team1sub = this.loginService.af.database.object("/teams/" + match.team1);
            match.team2sub = this.loginService.af.database.object("/teams/" + match.team2);
            return match;
          })
        });
        return tipp;
     });
   });
  }

输出没有显示错误,但它也不起作用。谁能给我一个显示第3级数据的提示?

1 个答案:

答案 0 :(得分:0)

我想尝试重新构建您的Firebase数据库 - 因为您已经达到了3级深度来获取一些数据,它应该更平坦。