【问题标题】:AngularFire NormalizedCollection and order in firebasearrayAngularFire NormalizedCollection和firebasearray中的顺序
【发布时间】:2016-08-22 12:09:53
【问题描述】:

我使用 AngularFire 和 Firebase-util 库。
我想按从最后一个元素到第一个插入(在此列表底部)的降序排列一个列表。

    var ref = firebase.database().ref();

    var nc = new firebase.util.NormalizedCollection(
      ref.child('demandes/'+$state.params.chatId+'/reponses'), // main path
      [ref.child('reponses'), 'widget2'] // second path
    ).select('widget2.timestamp_inverse', 'widget2.intitule', 'widget2.commentaires', 'widget2.prix')
    .ref();

    $scope.reponses = $firebaseArray(nc);

我看到订购取决于主要路径!但是这个主路径只是一个 Firebase 键的列表,比如 -AZE4AZ4RQ4F53。
我怎样才能像我想要的那样订购这个列表?服务器端或客户端(如果需要)...

【问题讨论】:

    标签: firebase firebase-realtime-database angularfire firebase-util


    【解决方案1】:

    我认为我不得不这样做:客户端
    使用 firebasearray,不要使用 track by $index,否则它会显示类似 "expected array but received ..." 的错误,并根据需要过滤和排序数组:

     <ion-item  ng-repeat="reponse in filteredItems  = reponses  | orderBy:'FIELD_CHOSEN':true ">
    

    如果您对服务器端降序排序有任何建议,很高兴与我分享:)
    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-08
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 2017-09-04
      相关资源
      最近更新 更多