Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 如何从firestore集合创建离子重新排序组_Ionic Framework_Collections_Google Cloud Firestore - Fatal编程技术网

Ionic framework 如何从firestore集合创建离子重新排序组

Ionic framework 如何从firestore集合创建离子重新排序组,ionic-framework,collections,google-cloud-firestore,Ionic Framework,Collections,Google Cloud Firestore,我需要从firestore集合创建一个离子再订购组。由于要重新排序的列表可以实时更新,因此可以更精确地从可观察对象中删除 我从@Mirinda Corwin这里()得到了一些代码 这是我根据米林达的回答改编的代码: import { Observable, ObjectUnsubscribedError } from "rxjs"; import { take } from 'rxjs/operators'; ... public membersListRef: AngularFiresto

我需要从firestore集合创建一个离子再订购组。由于要重新排序的列表可以实时更新,因此可以更精确地从可观察对象中删除

我从@Mirinda Corwin这里()得到了一些代码

这是我根据米林达的回答改编的代码:

import { Observable, ObjectUnsubscribedError } from "rxjs";
import { take } from 'rxjs/operators';

...

public membersListRef: AngularFirestoreCollection<any>;
public membersList$: Observable < any []>;
public membersList = {} as any;
public membersArray: any[];

...

this.membersArray = [];
this.membersListRef = this.firestore.collection(`/userProfile/${this.groupNumber}/membersList`);
this.membersList$ = this.membersListRef.valueChanges();

...

this.membersList$.take(1).subscribe((members) => {
  members.forEach(mdoc=>{
    console.log("id: , name:" + mdoc.id, mdoc.name);
       return  this.membersArray.push({id: mdoc.id, name:mdoc.name })
     })
   });
从“rxjs”导入{Observable,objectunsubscribederor};
从“rxjs/operators”导入{take};
...
公共成员名单:AngularFirestoreCollection;
公共成员列表$:可观察<任何[]>;
公共成员列表={}如有;
公共成员:任何[];
...
this.membersArray=[];
this.membersListRef=this.firestore.collection(`/userProfile/${this.groupNumber}/membersList`);
this.membersList$=this.membersList.valueChanges();
...
this.membersList$.take(1).subscribe((成员)=>{
members.forEach(mdoc=>{
console.log(“id:,name:”+mdoc.id,mdoc.name);
返回此.membersArray.push({id:mdoc.id,name:mdoc.name})
})
});

但是我得到了以下错误:“take不是可观察的属性”。

当前版本的RxJS更改了如何将运算符应用于流的方法,您应该使用“pipe”方法:


当前版本的RxJS更改了如何将运算符应用于流的方法,您应该使用“管道”方法:

this.membersList$.pipe(take(1)).subscribe(...);