查询订购不在angularfire2中工作

时间:2017-12-09 07:31:24

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

AngularFire2订购无效。

我有按钮更新'订购'。 switch-case的正确情况正在被触发,但结果与初始排序保持一致。

@Component({
  selector: 'app-compact-research-report-list',
  template: `
    <loader *ngIf="!(allRRs$ | async)" [loading]=true [message]="'loading view...'"></loader>
    <ul class="list-unstyled clearfix">
      <li class="youtube-list-item" [@fadeIn] *ngFor="let rr of (allRRs$ | async)">
        <app-compact-research-report [media]="rr"></app-compact-research-report>
      </li>
    </ul>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class CompactResearchReportListComponent implements OnInit {
      public allRRs$: Observable<ResearchReport[]>;
      ngOnInit() {
        this.authService.reportDDBS$.subscribe((order) => {
          console.log('Reportorder = ' + order);
          switch (order) {
            case 'uploadDate':
              this.allRRs$ = this.dalService.this.afDb.list(`research_reports-published/`, ref => ref.orderByChild('uploadDate')).valueChanges();
              break;
            case 'filename':
              this.allRRs$ = this.dalService.this.afDb.list(`research_reports-published/`, ref => ref.orderByChild('filename').valueChanges();
              break;
            case 'uploaderName':
              this.allRRs$ = this.dalService.this.afDb.list(`research_reports-published/`, ref => ref.orderByChild('uploaderName').valueChanges();
              break;
            case 'revDownloads':
              this.allRRs$ = this.dalService.this.afDb.list(`research_reports-published/`, ref => ref.orderByChild('revDownloads').valueChanges();
              break;
            default:
              this.allRRs$ = this.dalService.this.afDb.list(`research_reports-published/`, ref => ref.orderByChild('uploadDate').valueChanges();
          }
        });
      }
}

1 个答案:

答案 0 :(得分:0)

问题不在于Firebase。 将ChangeDetectionStrategy.OnPush更改为ChangeDetectionStrategy.Default会为我修复此问题。