Reputation: 363
In my .ts file I am trying to get a single value named 'index' from AngularFirestoreDocument.
interface item {
index:string;
}
export class appComponent{
constructor(
public router:Router,
public afs: AngularFirestore,
public afAuth: AngularFireAuth
)
itemCollection: AngularFirestoreCollection<item>;
items: any;
itemDoc: AngularFirestoreDocument<item>;
Item: Observable<item>;
ngOnInit() {
itemDoc = this.afs.doc(this.accounts+this.email).collection('Items');
}
}
just trying to retrieve the index value from itemDoc since I'm directly inside the Doc.
Upvotes: 2
Views: 742
Reputation: 19843
it should be
async ngOnInit() {
const docRef = await this.afs.collection('yourcollectionname').doc('yourdocId');
const data = (await docRef.get()).data();
}
Upvotes: 3