简体   繁体   中英

Ionic. How to use ngx-translate on string?

In Ionic 6 I'm getting data from a central JSON service that is resolving data on an /:id page like so {{ product.title }}. The central JSON also feeds the wishlist and search facility.

central.json > page/:id The JSON file is like this:

     public product: Product[] = [
{ 
  id:0,
  title: 'UK Information',
  description: 'Travel tips',
  extrainfo:'',
  ...

I need to use ngx-translate. In the past {{ product.title | translate }} would have pulled the data from assets/i18n/en.json and assets/i18n/fr.json.

Any ideas how I can use ngx-translate to get the dynamic text from strings on a page?

Thanks for any help!

您的对象在一个数组中。

<div>{{ product[0].title || translate }}</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM