Angular 在映射之前如何在rxjs中保存值
我有一个odata结果,看起来像这样 我想从这里获取“值”,在此之前,我想将@odata.count保存在localStorage中,或者只是记录它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):可观察{ 返回这
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']});
}