App Module.ts
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
HTML
<div class="container" *ngFor="let item of itemArray">
<div class="row">
<div class="col">
<p> <b>Name: </b> {{item.firstName}}</p> <---- translate First Name
</div>
</div>
<div class="row">
<div class="col">
<p><b>E-mail:</b> {{item.lastName}}</p><---- translate Last Name
</div>
</div>
<div class="row">
<div class="col">
<p><b>comment:</b> {{item.comment}} </p><---- translate Comment
</div>
</div>
</div>
getDataOfFirestoreDatabase
this.itemList = this.db.list('Messages');
this.itemList.snapshotChanges().subscribe(actions => {
this.itemArray = [];
actions.forEach(action => {
const z = action.payload.toJSON();
z['$key'] = action.key;
this.itemArray.push(z as messageDB);
});
});
注意:我需要在获取AngularFireDatabase之后转换数据,例如en或fr。我该怎么办?