gpt4 book ai didi

javascript - 排除 API 中的记录 - Ionic

转载 作者:行者123 更新时间:2023-11-30 19:57:32 27 4
gpt4 key购买 nike

我正在从 API 检索记录,我想隐藏具有 inventory_name = 'Better luck next time!' 的记录。我正在尝试使用 ngIf 使用我当前的代码,隐藏所有记录。有人可以告诉我我做错了什么吗?谢谢

vendor

  getSpin(){
return this.http.get<GamesRecords>(`${this.dataApiUrl}//some api`,
{ headers: new HttpHeaders().set('X-XSRF-TOKEN', this.getCookie('XSRF-TOKEN'))});}

页面的.ts

export class PrizesPage{


games: Games[];
inventory_name: string = 'Better luck next time!';

constructor(public navCtrl: NavController, public modalCtrl:
ModalController, public navParams: NavParams, public christmasProvider:
ChristmasProvider, private storage: Storage) {
console.log('constructor Testpage');

//christmasProvider.getDedi().subscribe();
}


ionViewDidLoad(){
this.christmasProvider.getSpin().pipe(
map((gamesResult: GamesRecords) => gamesResult && gamesResult.records)
).subscribe(gamed => {
this.games = gamed;
console.log(this.games);
});

页面的HTML

        <ion-item *ngFor ="let g of games" [ngClass]='g.inventory_name && g.status' tappable (click) = "gotoDetailspage(g.spin_result_id, g.inventory_id, g.display_name, g.status, g.inventory_name)">
<ion-row *ngIf="!inventory_name">
<ion-col align-self-start style="text-align: left;">
<p>{{ g.display_name }} </p>
<p style="width: 100%">Prize Won: {{ g.inventory_name}}</p>
</ion-col>

<ion-col align-self-end style="vertical-align: auto; text-align: right;">
<p [ngClass]='g.status'> {{ g.status }}</p>
</ion-col>
</ion-row>
</ion-item>

最佳答案

对于这一行:

<ion-row *ngIf="!inventory_name">

你是故意的吗?

<ion-row *ngIf="g.inventory_name !== inventory_name">

关于javascript - 排除 API 中的记录 - Ionic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53783389/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com