Answer the question
In order to leave comments, you need to log in
Asynchronous pipe or how to update the value after loading the data?
In various parts of the site, it is required to display amounts indicating the currency and some other modifications depending on the currency.
Information arrives from the back in the format
IMoney {
sum: number;
currencyId: number;
}
Answer the question
In order to leave comments, you need to log in
I think you can do it like this:
in the component where you need to use pipe, first
you request information about currencies,
loading: boolean = false;
ngOnInit() {
this.loading = true;
this.service.getInfoValute().subscribe(res => {
if (res) {
this.loading = false;
}
});
}
<ng-container *ngIf="!loading">
<div>{{ IMoney | pipe }}</div>
</ng-container>
As I understand it, you need to subscribe to currencies and to amounts
When both data packets come from the back, issue a derivative (amount, plus currency designation)
Sounds like
combineLatest
combineLatest(money$,currency$).subscribe(data = > /*тут работа с массивов, где data[0] - это последние пришедшие данные от money$ и data[1] - последние от currency$*/)
или
combineLatest(money$,currency$).subscribe(([money, currency]) = > /*...ваша логика*/)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question