在离子中,我使用foreach
语句来获取本地存储中的所有数据。现在我的问题是我没有在PIPE中收到这些数据
//我用来检索数据的代码
public transactions: Transaction[] = [];
constructor(public navCtrl: NavController, public navParams: NavParams,
public transactionService: TransactionProvider) {
console.log('ionViewDidLoad PortfolioPage');
this.transactionService.store.iterate((value) => {
this.transactions.push(value); //
}).then(res => {
console.log(res);
})
}
HTML代码
<div class="xs-row-item" *ngFor="let t of (transactions | async) | groupBy :'coin'">{{transactions|json}}{{t.coin}}</div>
我在管道中使用的代码:
export class GroupByPipe implements PipeTransform {
transform(source: Array<any>, field: string): Array<any> {
console.log(source) // <= this is empty
}
}