Advertisement
fred76

Pippo

May 21st, 2022
716
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // Nell BodymeasurementHttpService
  3.  public allTrainingPrograms$ = new BehaviorSubject<WeeklyTraining[] | null>(
  4.     null
  5.   );
  6.  
  7. findAllTrainingPrograms(limit: number)   {
  8.     return this.http
  9.       .get<WeeklyTraining[]>('/api/weeklyTraining', {
  10.         params: new HttpParams()
  11.           .set('limit', limit.toString())
  12.           .set('jwtc', this.jwtc!),
  13.       })
  14.       .pipe(
  15.         map((res) => {
  16.           if (res.length > 0) {
  17.             console.log(res)
  18.             this.allTrainingPrograms$.next(res);
  19.           }
  20.         })
  21.       );
  22.   }
  23.  
  24. //nel component padre che contiene tutti i container della tab
  25.  
  26.  this.bodymeasurementHttpService
  27.       .findAllTrainingPrograms(50)
  28.       .subscribe()
  29.       .add(() => console.log('Unsubscribed from findAllTrainingPrograms'));
  30.  
  31.  
  32. nell component trainingList
  33.  
  34. <div *ngIf="bodymeasurementHttpService.allTrainingPrograms$ | async; let trainings"> bla bla </div>
Advertisement
RAW Paste Data Copied
Advertisement