【问题标题】:Using two variable in *ngIf在 *ngIf 中使用两个变量
【发布时间】:2020-11-07 14:42:28
【问题描述】:
<ion-col size="12" *ngFor="let day of weekdays">
     <h5>{{day | titlecase }}</h5>
     <ion-grid fixed>
         <ion-row>
         <ng-container *ngFor="let item of category.menu_items">
         <ion-col sizeLg="4" size="12" *ngIf="item.menu_item_books['0'].{{day}}">

我有这样的数据:

item.menu_item_books['0'].monday: false 

我想使用这些数据来显示元素。我创建一个数组:

weekdays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];

我想在 *ngIf 中使用 weekdays 数组的元素。我该怎么做?

【问题讨论】:

  • 你能重新表述一下这个问题吗?你想让 if 语句做什么?

标签: angular angular-ng-if


【解决方案1】:

你可以这样写

*ngIf="item.menu_item_books['0'][day]"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-01
    • 2020-11-11
    • 2019-05-08
    • 1970-01-01
    相关资源
    最近更新 更多