【问题标题】:Displaying entries from fire base whose dates have not passed显示日期尚未过去的火力基地的条目
【发布时间】:2019-12-05 22:56:17
【问题描述】:

我正在开发一个用户可以在某些日期预订的应用程序,预订后我希望用户能够查看他的约会,但只能查看日期尚未过去的约会。

我尝试将检索到的记录的日期与我创建的具有最新日期但没有运气的日期值进行比较。

HTML

<ng-container *ngFor="let a of Appointments|async">
    <ng-container *ngIf="id == a.UID && a.Date.Day &ge; d">
      <ion-item >
        <ion-label> {{a.Date.Day}} </ion-label>
      </ion-item>
    </ng-container>
  </ng-container>

打字稿

 id;       //Stores ID of logged in user.
  users;   //Stores list of all users.
  Appointments;
  date;
  d;
  constructor(public afAuth:AngularFireAuth, public navCtrl: NavController, public navParams: NavParams, public firebase: FirebaseProvider) {
    afAuth.authState.subscribe( user => {
      if (user) { this.id = user.uid }
    });
    this.Appointments = this.firebase.getBookedAppointments();
    this.date = new Date();
    this.d = moment(this.date).format('YYYY/MM/DD');
  }

我测试了从 firebase 检索到的数据的值,我可以很好地查看和输出该值。但是,当我包含条件时:-

a.Date.Day &ge; d

我收到此错误 https://imgur.com/a/FlJpw0c

【问题讨论】:

    标签: typescript firebase ionic3 angularfire2


    【解决方案1】:

    在 Typescript/Javascript 中,您不能使用 ≥ 符号,这是您在代码中尝试执行的操作。如果您查看您发布的错误,它会显示“意外字符 [≥]”。

    “大于或等于”的正确运算符是&gt;=Docs.

    【讨论】:

      猜你喜欢
      • 2016-09-17
      • 2011-02-04
      • 1970-01-01
      • 2015-05-23
      • 2018-02-15
      • 2020-08-05
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      相关资源
      最近更新 更多