I try to understand .valueChanges() and .subscribe() I use AngularFire2 and Angular5
My code works but I don't understand how it works.
My Component :
ngOnInit() {
this.itemService.getLastUnicorns().subscribe(items => {
this.items = items;
console.log(items);
});
}
console.log give a beautiful array : Array [ {…}, {…} ]
My service :
getLastUnicorns() {
this.items = this.afs.collection('unicorns', ref => ref.limit(2)).valueChanges();
console.log(this.items);
return this.items;
}
console.log give Object { _isScalar: false, source: {…}, operator: {…} }
euh WTF ?
QUESTION: what's happened in the service to give this strange object and how I am able to recover a beautiful array in my component ? Thank you