【发布时间】:2020-05-01 13:07:39
【问题描述】:
我正在尝试获取文档创建的确切时间。
为此,我使用以下导入
import { Firebase } from '@ionic-native/firebase/ngx';
import { AngularFirestore } from '@angular/fire/firestore';
import { AngularFirestore } from '@angular/fire/firestore';
我的构造函数如下。
constructor(private aF: AngularFireStore, private firebase: Firebase, private cS: CartService, private ui: UiService){}
这是我尝试添加时间戳的方法。
checkout2() {
const pickup = this.pickup;
const deliveryname = this.deliveryname;
const location = this.location;
const note = this.note;
const deliverystate = this.deliverystate;
const cart = this.cS.getCart();
const total = this.getTotal();
const uid = this.aS.getInfo();
return new Promise<any>((resolve, reject) => {
this.aF.collection('/ordenes').add({
cart,
pickup,
location,
deliveryname,
createdAt: this.firebase.firestore.Timestamp.fromDate(new Date()),
note,
total,
deliverystate,
uid
})
.then(
(res) => {
resolve(res);
this.cS.cleanCart();
this.cS.cleanItemCount();
this.close();
},
err => reject(err)
);
});
}
我收到一条错误消息:
“Firebase”类型上不存在属性“firestore”
我不知道我是否导入了错误的库,提前感谢您的帮助!
【问题讨论】:
标签: angular firebase ionic-framework google-cloud-firestore