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();
}
});
}
}
答案 0 :(得分:0)
问题不在于Firebase。
将ChangeDetectionStrategy.OnPush
更改为ChangeDetectionStrategy.Default
会为我修复此问题。