ok. I'm trying to add some methods to model class of an object which is streaming in observable, I want for example to multiply two propoerties and return result in that new property. This is working when data stream is displayed through async pipe, but how can I do this with normal subscribed observable? I tried to return getter through async - await but that is not working
export interface IProduct {
price: number;
tax: string;
}
export class Product implements IProduct {
constructor(
public price: number,
public tax: string,
) { }
get grossPrice() {
return this.price * parseInt(this.tax)
}
}
export class ProductService {
private url = ''
constructor(private http: HttpClient){ }
getAll(): Observable<Product[]> {
return this.http.get<Product[]>(this.url)
}
}
@Component({
template: `<div *ngFor="let product of products">
{{ product.grossPrice }}
</div>
`
})
export class ProductsViewComponent implements OnInit, OnDestroy {
products: Product[] = [];
constructor(private productService: ProductService){}
this.productService
.getAll()
.subscribe(data => this.products = data)
}