Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.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
Angular 在映射之前如何在rxjs中保存值_Angular_Rxjs_Ngrx - Fatal编程技术网

Angular 在映射之前如何在rxjs中保存值

Angular 在映射之前如何在rxjs中保存值,angular,rxjs,ngrx,Angular,Rxjs,Ngrx,我有一个odata结果,看起来像这样 我想从这里获取“值”,在此之前,我想将@odata.count保存在localStorage中,或者只是记录它 getAllBankAccounts(url: string): Observable<BankAccount[]> { return this.http.get(url).pipe(map((res) => res['value'])); } getAllBankAccounts(url:string):可观察{ 返回这

我有一个odata结果,看起来像这样

我想从这里获取“值”,在此之前,我想将@odata.count保存在localStorage中,或者只是记录它

  getAllBankAccounts(url: string): Observable<BankAccount[]> {
return this.http.get(url).pipe(map((res) => res['value']));
}
getAllBankAccounts(url:string):可观察{
返回这个.http.get(url).pipe(map((res)=>res['value']);
}
如何返回“value”属性中的observale数组,但在此之前存储'@odata.count'

您可以使用来挖掘可观察到的值

getAllBankAccounts(url: string): Observable<BankAccount[]> {
  return this.http.get(url).pipe(tap(res=>console.log(res['@odata.count'])),map((res) => res['value']));
}
getAllBankAccounts(url:string):可观察{
返回这个.http.get(url).pipe(点击(res=>console.log(res['@odata.count'])),map((res=>res['value']);
}

要将@odata.count保存到本地存储,请尝试此新版本以获取最后答案

getAllBankAccounts(url: string): Observable<BankAccount[]> {
  return this.http.get(url).pipe(tap(res=>localStorage.setItem('odata',res['@odata.count'])),map((res) =>{ 
//here do anything 
res['value']}));
}
getAllBankAccounts(url:string):可观察{
返回此.http.get(url).pipe(点击(res=>localStorage.setItem('odata',res['@odata.count'])),map((res)=>
//这里有什么事吗
res['value']});
}